I have to display which direction the user is pointing the Android device.
I am using Sensor.TYPE_ACCELEROMETER
, Sensor.TYPE_MAGNETIC_FIELD
to get the azimuth, pitch, roll. But I am to able to figure out how to get directions (North, south, east , west,...) from this.
Please help
Thanks
To point the north you can calculate a rotation in degrees :
float rotation = -azimut * 360 / (2 * 3.14159f);
You can see the following compass example which make uses of accelerometer and magnetic field : http://www.codingforandroid.com/2011/01/using-orientation-sensors-simple.html
Azimuth on Wikipédia : http://en.wikipedia.org/wiki/Azimuth