Measuring the exact angle of rotation of the device in android
I need to get the exact angle of my android device from each axis.
First I have to say that I was browsing the web pages as well as stackoverflow and I have seen pages like this:
How to measure the tilt angle of a phone in the XY plane with an accelerometer in Android
Get android rotation angle along x axis
But they didn't help. I've used some of them, but they give the wrong values.
If the axis in the device looks like this:
I need to get this rotation angle:
I don't want to use any hardware sensor other than the accelerometer and I am working with API 17 . I think it's possible based on racing games, but I don't know how to do it.
I would be grateful if you can help me. Thanks to
source to share
It is not possible to get all rotations with TYPE_ACCELEROMETER
. You also need TYPE_MAGNETIC_FIELD
. If you don't care how sensitive the values ββare for fast travel, you need TYPE_GRAVITY
or TYPE_ACCELEROMETER
together with TYPE_MAGNETIC_FIELD
.
For z-axis rotation, you can follow the first link in your question.
For rotation in x and y axes, you can use pan and roll and screen.
source to share