Android compass accuracy - when to calibrate?

I am developing an application that provides some augmented reality features using a compass. I found out that sometimes I need to calibrate my compass so that it works well.

How to find out (software) that calibration is necessary?

I mean, I know how to calibrate the compass using a figure with 8 figures, but I want to find that calibration is required and display some warning for the user ("Your compass is not accurate enough, please calibrate your compass sensor.") .

Is this possible, please? Thank!

+4
source share
1 answer

onAccuracyChanged() SensorEventListener.

:

//In SensorEventListener interface implementation    
@Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
        switch(sensor.getType()){
            case Sensor.TYPE_MAGNETIC_FIELD :
                switch(accuracy) {
                    case SensorManager.SENSOR_STATUS_ACCURACY_LOW :
                        doSomething();
                        break;
                    case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM :
                        doSomethingElse();
                        break;
                    case SensorManager.SENSOR_STATUS_ACCURACY_HIGH :
                        doNothing();
                        break;
                }
                break;
            default:
                break;
        }
    }

: fooobar.com/questions/303758/...

" , , . ".

+2

All Articles