views:

146

answers:

1

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

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

In the above diagram the phone would display "North". Since the user (the stick with 0 for his head) is holding out the phone (the [] in the diagram) pointing north.

I found this example. I understand what it's doing except it seems to calculate yaw, pitch, roll, and inclination. What are those and how would I use them to simply find which way the phone is pointing?

Also this android documentation mentions X, Y, and Z axises but I don't see anywhere that says how those axises correspond to the phone? Is Z going from the bottom of the phone to the top?

+1  A: 

this is how the axis (axiy?) look like.

I couldn't find a link to the cheat sheet I use, but it looked sort of like this.

In summary, you want to register to listen for Sensor.TYPE_ORIENTATION, from the incoming array of values get, value[0] and that should show you your angle (from North I believe).

some example from *android.com

Karol Wilk
Thanks. What happens if the phone is in landscape mode?
Greg
Karol Wilk