react-native-compass-heading
react-native-compass-heading copied to clipboard
Is it possible to get accuracy information on Android?
Nowadays accuracy in Android is pseudo constant 1. At least this (https://stackoverflow.com/questions/28175420/android-compass-accuracy-when-to-calibrate) StackOverflow question and answer gives more options for the value. They come from SensorManager class. Some examplery code of the approach decribed there:
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;
}
Those functions should be returning a value between 0 and 1. For Low there would be value 0, for Medium 0.5 and High 1 for example. Would that work?