If you have access to the accelerometer, you can use the getOrientation () method, which returns the azimuth, step and roll, as determined from the two sensors, and is calculated using the getRotationMatrix () method.
edits
Reply to comments ... I see your question now. I'm sorry. Using only a 3-axis magnetometer, you cannot accurately obtain the azimuth, pitch and roll, unless the device is parallel to the surface of the earth. Remember, when using a compass, the needle compass and one having it: a) on the spindle so you can see and manually compensate for the tilt, or b) sealed in liquid so you can get the bubble level in the center? To get the azimuth:
azimuth = arctan(y/x)
Now, if you tilt the phone, the errors in the perception of the x / y plane can become large. Now you need to figure out the slope (using the accelerometer), then measure the magnetic force of the Z axis, and then use three to compensate. This is what you know as getRotationMatrix () and getOrientation ().
In part, I think Sensor.TYPE_ORIENTATION is deprecated in API 8 because there is no separate orientation sensor per se . This is a combination of magnetic field and acceleration sensitivity.
The good paper I dug up that covers it all:
http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf
source share