How to detect android device rotation parallel to the ground?

女生的网名这么多〃 提交于 2021-01-29 02:10:17

问题


As I know, the most of android devices allows to detect rotation by accelerometer, but I've noticed, that it doesn't detect rotation parallel to the ground. For example, if I put the device on a table and turn it around, no one of accelerometer indicators doesn't change.

At the picture, it's called "alfa" rotation. So how can I detect this kind of turning?


回答1:


For sensing rotation around z-axis you need to implement a compass function. A good tutorial is this one. To make the resulting values more stable you need to implement some algorithm which smoothes your incoming data (averages over a queue of data, filtering outliers, etc.). Here is a good overview.



来源:https://stackoverflow.com/questions/38244405/how-to-detect-android-device-rotation-parallel-to-the-ground

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!