简体   繁体   English

构建计步器时 onAccuracyChanged 方法的重点是什么?

[英]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.您可能不需要它,但必须声明它以匹配签名。

Source 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么时候“这个”分配了内存位置,在什么时候可以在java中调用一个方法 - when is “this” assigned memory location and at what point can a method be called in java 覆盖getInsets()方法有什么意义? - What is the point of overriding the getInsets() method? 无论如何,当一个方法只有一种泛型类型时,将其设为泛型有什么意义? - What is the point of making a method generic when it has only one generic type anyway? 类Array中方法排序重载的意义是什么? - what is the point of the overloading of the method sort in class Arrays 静态valueOf()方法有什么意义? (枚举) - What is the point of the static valueOf() method? (enumerations) 在本地构建时AssertJ没有此类方法错误 - AssertJ no such method error when building locally "为 lambda 函数构建 InvokeRequest 时没有这样的方法 memberName" - No such method memberName when building InvokeRequest for lambda function 构建phonegap项目时出了什么问题? - What's wrong when building phonegap project? 在所有方法调用中允许类型见证有什么意义? - What is the point of allowing type witnesses on all method calls? 构建Java Maven模块时出现方法required()错误 - method required() error when building java maven module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM