Reputation: 42417
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.
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.
Upvotes: 0
Views: 69
Reputation: 42417
The problem no longer occurs when I set the sensor sampling rate to any of the following:
SENSOR_DELAY_GAME
SENSOR_DELAY_FASTEST
54999
or lowerUnfortunately, if the sensor is already being listened to by another app, the sampling rate that was requested by the other app is used instead of the value requested by my app. So if another app is already listening to the sensor with SENSOR_DELAY_NORMAL
, for example, my app only gets sensor updates at that rate, leaving my app completely unable to workaround the bug.
Upvotes: 1