this is one of the auto-generated functions I get when implementing
SensorEventListener
i've searched and didn't find anymore than this description: "Do something if sensor accuracy changes." when and how does the proximity sensor accuracy changes ? and in what way can this be useful on my apps ?
According to my understanding,
OnAccuracyChanged
method is invoked whenever a sensor reports with different accuracy andonSensorChanged
method is called whenever a sensor reports a new value.I too had the same question, as in how to make use of
onAccuracyChanged
method.Let's say you want the sensor data only when the accuracy is high,nothing below that. One way to do that is to create a new global variable. Inside the
onAccuracyChanged
method, initialize it to some value, and insideonSensorChanged
function, add anif..else
condition.Sample code:
Now use condition as
if (con==1)
to do the required changes.P.S. According to the android documentation.
Called when the accuracy of a sensor has changed. See SensorManager for details.Parameterssensor The ID of the sensor being monitored accuracy The new accuracy of this sensor. So whenever the accuracy changes,you will have a reference to that change. Please let me know if am missing something. Thanks.