How to get compass direction

I want to show the direction on the screen that the phone is handling. For example:

0 |- [] |_ South --- North 

In the above diagram, the phone displays "North." Since the user (stick with 0 for the head) holds out the phone ([] on the diagram) pointing north.

I found this example . I understand what he is doing, except that it seems to calculate yaw, pace, throw and addiction. What is it and how will I use them to just find how the phone is indicated?

In addition, the x, y, and z axes are mentioned in this android documentation , but I don't see anywhere where it says that these axes correspond to the phone? Is the Z from the bottom of the phone to the top?

+6
android compass-geolocation
source share
1 answer

this is what the axis looks like (axiy?).

I could not find the link to the cover that I use, but it looked like this .

In general, you want to register to listen to Sensor.TYPE_ORIENTATION, from the incoming array of get values, the value is [0], and this should show you your angle (from the north, I think).

some example from * android.com

+5
source share

All Articles