Steps to reproduce
Register a listener for the gravity sensor with normal sampling period. Either use your own code (basic example below) or just install My Sensors, making sure to set the sensor update rate to Normal via the menu.
Sensor gravitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); sensorManager.registerListener(callback, gravitySensor, SENSOR_DELAY_NORMAL);
Observe the sensor output. The Y axis (
event.values[1]
) should report ~9.7 when the device is upright.- Give the device a hard, quick shake/swing once or twice. Then hold it upright again.
- Look at the sensor output after doing this:
- For the first 2 seconds, the Y axis value transitions from 9.7 to -9.7.
- For the next 6 seconds, the Y axis value remains inverted (-9.7).
- For the next 2 seconds, the Y axis value transitions back to 9.7.
This look like a bug to me because it seems completely counter-intuitive to have bad data for 10 seconds every time the user shakes or swings the device.
Device details
- Using a Samsung Galaxy S5 (G900I)
- Running Android 5.0 (also happened after upgrading to Android 6)
- Affected sensors
- Gravity Sensor (Samsung Electronics) (Version 3)
- MPL Rotation Vector (Invensense) (Version 1)
- MPL Game Rotation Vector (Invensense) (Version 1)
- Orientation Sensor (Samsung Electronics) (Version 1)
My questions
- Is this normal behaviour for this device? (Does it happen on your Galaxy S5?)
- Is this normal behaviour for Android devices in general? (Does it happen on your Android device(s) with the above sensor types?)
- Is there a way to prevent this from happening?