Plam Plam - 5 months ago 12x
Java Question

What is the point of onAccuracyChanged method when building a pedometer?

I am building my pedometer and I wanted to know why it needs the onAccuracyChanged method. I am wondering because it requires absolutely no code within it. Just made me wonder why it has to be inside the class if it does absolutely nothing?

public void onAccuracyChanged(Sensor sensor, int accuracy) {



Because if you implement SensorEventListener you also have to declare the abstract methods it has. Which is

public abstract void onAccuracyChanged (Sensor sensor, int accuracy)

Called when the accuracy of the registered sensor has changed. And,

public abstract void onSensorChanged (SensorEvent event)

Called when sensor values have changed. Otherwise you get complier errors. You might not need it, but it has to be declared to match the signature.