I am making an app in which am using two sensors.
TYPE_MAGNETIC_FIELD
TYPE_GRAVITY
I initialized the respective sensors and then in onSensorChanged
function, am fetching the data and doing the calculations on the same.
I have one simple question, how can I use onAccuracyChanged
function to filter out data? I want the data with medium and high accuracy!!
I printed basic statements to see what kind of accuracy am getting while debugging the app.
Code :
`@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// Do something here if sensor accuracy changes.
// You must implement this callback in your code.
// I initialized mValuen as mValuen = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (sensor == mValuen) {
switch (accuracy) {
case 0:
System.out.println("Unreliable");
break;
case 1:
System.out.println("Low Accuracy");
break;
case 2:
System.out.println("Medium Accuracy");
break;
case 3:
System.out.println("High Accuracy");
break;
}
}
}`
As per my understanding, whenever a sensor reports a new value onSensorChanged
function is called. So I can't really call that function explicitly(Even if I could,that will anyway be called upon whenever the sensor reports a new value).
All of my calculations are in that function. How do I filter out data with medium and high accuracy. Thanks.