Detecting movement using accelerometer - (Orientat

2019-07-19 08:50发布

问题:

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.