Ahmed
Ahmed

Reputation: 15039

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

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.

Upvotes: 2

Views: 1887

Answers (1)

Ali
Ali

Reputation: 58461

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.

Upvotes: 2

Related Questions