如何检查传感器事件侦听活动中 OnAccuracyChanged 方法的准确度值?
我正在制作一个用作指南针的应用程序,但我想校准加速度计和磁场传感器以使其更加高效。
从 API 中我了解到这是可能的,并且您可以检查一些值,例如:
SENSOR_STATUS_ACCURACY_HIGH
我怎样才能实现这个值?
我在OnAccuracyChanged
里面思考,但不知道怎么做!
I'm making an application that works as a compass, though I want to calibrate the accelerometer and the magneticfield sensors to make it more efficient.
From the API I understand that this is possible, and that there are some values that you can check, for example:
SENSOR_STATUS_ACCURACY_HIGH
How can I achieve this value?
I was thinking inside OnAccuracyChanged
, but don't know how!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当传感器开始以不同的精度报告时,系统会调用侦听器的 OnAccuracyChanged 方法 - 这是您从传感器收到的信息,因此您无法设置它。 SensorManager API 提供了一些枚举,可让您检查传感器报告的准确性。
The OnAccuracyChanged method of your listener is invoked by system, when a sensor begins to report with different accuracy - this is something you receive from the sensor, so you can not set it. SensorManager API has got some enumerations to let you check what accuracy is a sensor reporting at.
下面的代码
派生了一个实现 SensorEventListener 的类。
注册传感器监听器。
Here is the code
Derived a class that implements SensorEventListener.
Register the sensors Listener.