3

I'm studying the Android API and bumped into the onAccuracyChanged method.

Googled and searched on StackOverflow but I still don't understand in what occasion the accuracy of a sensor might change.

I tried implementing the code in the answer of the thread below: onAccuracyChanged, why?

Testing this, I don't have a clue how to trigger this method. Even though it might not be useful in any case. There must be a reason why this was provided in the interface.

So out of curiosity. Does anyone know how I might trigger this call?

Community
  • 1
  • 1
Jens Ackou
  • 151
  • 11

1 Answers1

4

An example of a sensor on mobile devices that sometimes needs calibration is a compass.

So you might be able to observe accuracy changed events by experimenting with the sensor type TYPE_MAGNETIC_FIELD.

The results you receive will be from this list:

  1. SENSOR_STATUS_ACCURACY_HIGH This sensor is reporting data with maximum accuracy
  2. SENSOR_STATUS_ACCURACY_LOW This sensor is reporting data with low accuracy, calibration with the environment is needed
  3. SENSOR_STATUS_ACCURACY_MEDIUM This sensor is reporting data with an average level of accuracy, calibration with the environment may improve the readings
  4. SENSOR_STATUS_NO_CONTACT The values returned by this sensor cannot be trusted because the sensor had no contact with what it was measuring (for example, the heart rate monitor is not in contact with the user).
  5. SENSOR_STATUS_UNRELIABLE

So you can see the states reflect sensors that are either performing well, need to be calibrated, or just don't work.

x-code
  • 2,940
  • 1
  • 18
  • 19
  • Perfectly valid answer IMO. Thanks! – Jens Ackou Sep 08 '16 at 22:06
  • What happens if we do not recalibrate the sensor? Besides not being accurate of course. I mean, is there any risk that the sensor will stop sensing? I'm randomly getting missing data whenever I move the device on which I'm testing. Not sure if its a hardware problem or this accuracy might be impacting. – Roger May 07 '18 at 20:49