Does gravity sensor return right values if device is in motion? I thought that gravity sensor use accelerometer to recognize gravitation direction. Are these two sensors different piece of hardware?
The Gravity sensor is what Android calls a 'software sensor' and calculates its values using more than one hardware sensor.
The software Gravity sensor is only available if the device has a gyroscope. By combining accelerometer data with gyroscope data, the acceleration due to moving the device can be filtered out to leave the pure gravity signal. So yes, it will return the right value under motion.
Thus, the Gravity sensor gives a much better signal for device orientation than just the accelerometer on its own.
Combining sensor values is called sensor fusion and important for high quality measurement values.
The Android Documentation describes the Gravity Sensor.
Unfortunately, many Android devices lack a Gyroscope, and thus, will have no Gravity sensor either. This leaves you with a sub optimal signal from just the accelerometer alone, giving a lower quality user experience compared to Android devices with both sensors, and lower quality experience compared to iOS devices.
You can block installations on incompatible devices by using a Google Play requirement specification as follows:
<uses-feature android:name="android.hardware.sensor.gyroscope" />
Albert Einstein answered this question in 1911
A little reflection will show that the law of the equality of the inertial and gravitational mass is equivalent to the assertion that the acceleration imparted to a body by a gravitational field is independent of the nature of the body. For Newton's equation of motion in a gravitational field, written out in full, it is:
(Inertial mass) \cdot (Acceleration) = (Intensity of the gravitational field) \cdot (Gravitational mass). It is only when there is numerical equality between the inertial and gravitational mass that the acceleration is independent of the nature of the body.
— Albert Einstein
We cannot differentiate the measurement of acceleration from the measurement of gravity since they are equivalent to the observer. Even if the Android had two sensors they would both be measuring the same thing.
© 2022 - 2024 — McMap. All rights reserved.