Reputation: 1338
Is there any way to disable batching of sensor results (from my application's code) in Android 4.4?
I am aware it might not be the best idea, but I am also sure it's worthy in my app's case despite of higher battery consuming.
Upvotes: 0
Views: 464
Reputation: 2773
If you call
registerListener (SensorEventListener listener, Sensor sensor, int rateUs, int maxBatchReportLatencyUs)
then you enable sensor batching. if you call the older version:
registerListener (SensorEventListener listener, Sensor sensor, int rateUs, Handler handler)
Then sensor batching shouldn't occur. Another workaround that could work:
When using the SensorManager
, call getFifoMaxEventCount()
to get the maximum number of sensor events it can save, and divide that number by the rate at which your app desires each event. Use that calculation to set wake alarms with AlarmManager
that invoke your Service (which implements the SensorEventListener
) to flush the sensor.
also look here: https://developer.android.com/about/versions/android-4.4.html#BatchSensors
Upvotes: 1