为什么Android手机静止时传感器采样率会变得太低?
我编写了一个简单的应用程序来读取加速度计数据,当我将手机放在桌子上并保持安静时,我发现采样率太低(甚至 5 秒采样一次)。我将采样率设置为“最快”,它的采样率始终很高。
我想知道 Android 为何以及如何做到这一点?我猜想 jni 或硬件总是读取数据,但当它发现两个样本之间没有变化时,它会丢弃数据。
I write a simple app to read accelerometer data and I found that sampling rate is too low(even one sample 5 seconds) when I put phone on the table and keep quiet. I set sampling rate as FASTEST it's sampling rate always is high.
I want to know why and how does Android do this? I guess jni or hardware always read data but it discard data when it find there is no change between two sample.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您可以从 的文档中看到的传感器侦听器当传感器发生变化时,调用过程
onSensorChanged
。这意味着如果您保持设备不动,传感器值不会改变。我不得不承认,大多数手机都会给传感器值添加噪音,而且这些值总是在变化;您应该为您的手机感到“自豪”——它不会增加太多噪音。
As you can see from the documentation of the sensor listener the procedure
onSensorChanged
is called when the sensor changed. This means that if you hold the device still the sensor values won't change.I have to admit that most phones add noise to sensor values and these values are always changing; you should be 'proud' of your phone - it doesn't add a lot of noise.