In Android can I programmatically detect that the compass is not yet calibrated?

前端 未结 1 1834
广开言路
广开言路 2020-12-13 20:32

I\'ve found that when I start up my game the compass is often out of whack. Objects will fly around and not be where they\'re supposed to be. But, if I move the phone in a f

相关标签:
1条回答
  • 2020-12-13 21:29

    In SensorEventListener there is a function onAccuracyChanged(Sensor sensor, int accuracy) in which you can check the accuracy of the device's magnetometer. There are 4 levels of accuracy (from class SensorManager):

    SENSOR_STATUS_ACCURACY_HIGH = 3
    SENSOR_STATUS_ACCURACY_MEDIUM = 2
    SENSOR_STATUS_ACCURACY_LOW = 1
    SENSOR_STATUS_UNRELIABLE = 0
    
    0 讨论(0)
提交回复
热议问题