Detecting movement using accelerometer - (Orientation is not changing)?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-15 07:13:14

问题


I understand that we can detect orientation and its changes using accelerometer. Like whether the mobile phone is placed upside down, sideways or whatever.

Can we detect movement of the phone (given the phone orientation is not changing)?

Like the mobile phone is placed in a car and the car starts to move. In this case the mobile's orientation is not necessarily changing but can I detect this using accelerometer?

I am looking this feature in API-8 at the most.


回答1:


Yes. Look at LINEAR_ACCELERATION for example. Even if the orientation is not changing you will see changes in the acceleration.

Just don't try to integrate it to get velocity or position because it is not accurate enough for that.


Look at the change in length of TYPE_ACCELEROMETER (i.e. sqrt(x^2+y^2+z^2)). Define a threshold and if the change exceeds the threshold then the device has been moved.



来源:https://stackoverflow.com/questions/13345291/detecting-movement-using-accelerometer-orientation-is-not-changing

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