When developing a compass in android, it is possible to check for reliability of sensors by inspecting the accuracy parameter passed in
onAccuracyChanged(Sensor sensor, int accuracy)
This parameter can only be 0,1,2, or three for
SENSOR_STATUS_UNRELIABLE, SENSOR_STATUS_ACCURACY_LOW, SENSOR_STATUS_ACCURACY_MEDIUM, and SENSOR_STATUS_ACCURACY_HIGH
respectively.
However, I can see many applications on the android market which display a progress-bar gauge that seems to reflect an accuracy that is divisible by more than just 4 values, in other words, these applications seems to indicate an accuracy range that is much more precise than the 4 constants.
How w开发者_运维技巧ould someone do this?
There are probably using time averaging to return a better or worse result since there are the constants for SENSOR_DELAY_* when you register your sensor listener. If you add another layer of time averaging on top of what the system gives you, you should be able to improve accuracy at the cost of performance.
精彩评论