Last Updated: February 25, 2016
·
359
· TomTasche

random accuracy in SensorEvent.accuracy

most people won't bother much about the accuracy of the reported sensor data, but for the company I'm working for this information is crucial. on Nexus 5 and Galaxy S4 (and possibly some other devices) we noticed that the value stored in the SensorEvent (given via SensorEventListener.onSensorChanged) is seemingly random (ranging from -100 to +100, instead of holding one of the SensorManager.SENSOR_STATUS_* constants.

we only saw this happen for sensors of type
Sensor.TYPE_ROTATION_VECTOR

this was reported and fixed by google for android lollipop: https://code.google.com/p/android-developer-preview/issues/detail?id=1453

workaround for older versions of android is to only use the accuracy given via SensorEventListener.onAccuracyChanged, which always reports the correct accuracy so far.