[英]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.我正在构建我的计步器,我想知道为什么它需要 onAccuracyChanged 方法。 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?只是让我想知道如果它绝对什么都不做,为什么它必须在课堂内?
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
Because if you implement SensorEventListener you also have to declare the abstract methods it has.因为如果你实现 SensorEventListener 你还必须声明它的抽象方法。 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.您可能不需要它,但必须声明它以匹配签名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.