简体   繁体   English

及时获取加速度计值

[英]Get accelerometer values in time

I have to get the accelerometer values in time. 我必须及时获取加速度计值。 I saw the Sensor class and the SensorEventListener but this listener notify only when the value changes and I need a periodic notification (also if the value do not change). 我看到了Sensor类和SensorEventListener但是此侦听器仅在值更改时通知,并且我需要定期通知(也在值不更改时)。 Otherwise I would like to continuously read the accelerometer value but it is not possible according to this thread: Get current SensorEvent value 否则,我想连续读取加速度计值,但是根据此线程是不可能的: 获取当前的SensorEvent值

What can I do? 我能做什么?

Why do you need to continuously "read" the sensor values even when they are the same as before? 为什么即使与以前相同,也需要连续“读取”传感器值? If you need to calculate some output on a regular basis, then a better solution might be to set up a timer that triggers on the required intervals at which time you use the values from a set of variables that are updated whenever the sensor values change. 如果您需要定期计算一些输出,那么更好的解决方案可能是设置一个计时器,该计时器以所需的时间间隔触发,在该时间间隔内,您将使用一组变量中的值,只要传感器值发生更改,这些变量就会更新。 That way even if they don't change, the timer will initiate the calculations. 这样,即使它们没有变化,计时器也将启动计算。

Kaamel Kaamel

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM