If you have access to the accelerometer, you can use the getOrientation()
method, which returns azimuth, pitch, and roll as determined from the two sensors, and calculated via the getRotationMatrix() method.
EDITS
Response to comments... I see your question now. Sorry. With just the 3-axis magnetometer, you can't accurately get azimuth, pitch, and roll except when the device is parallel to the surface of the earth. Remember using a needle compass and having it either a) on a spindle so you can see and manually compensate for tilt, or b) sealed in liquid so you can get the bubble level to the center? To get azimuth:
azimuth = arctan(y/x)
Now, if you tilt the phone, the errors in the x/y plane sensing can get big. Now you need to figure out the tilt (with the accelerometer), then measure the Z-axis magnetic strength, and then use the three to compensate. This is essentially what you know as getRotationMatrix() and getOrientation().
Part of the reason I think Sensor.TYPE_ORIENTATION was deprecated in API 8 was because there isn't a separate orientation sensor per se. It is a combination of magnetic field and acceleration sensing.
A good paper that I dug up that covers it all:
http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf