I recently tried out the Compass inside Androids 4.0 API-Demos. It works as long as you hold your phone in portrait-mode, but as soon as you put it into landscape, the “North” is pointing in another direction than before. I thought that it was clearly stated here that
The coordinate-system is defined relative to the screen of the phone in its default orientation. The axes are not swapped when the device’s screen orientation changes.
But thats exactly what happens!
Why the Compass is pointing to a wrong direction? Is the above statement untrue, or is it just a bug inside the computation of the data by the API-samples?
the compass demo is indeed incomplete. You need to take the device orientation into account when drawing a compass on the screen.
Have a look at this question for more details.
This is also a nice discussion of the subject.
I also have a working example on my github you can use. (its too much code to paste in here) The relevant classes are CompassSensorListener.java and CompassHelper.java.
Cheers