Getting magnetic field results as degrees

by Mark Murphy » Tue, 15 Dec 2009 08:45:31 GMT

Sponsored Links

That's because you don't. 

Or, to quote from the docs:


All values are angles in degrees.

values[0]: Azimuth, angle between the magnetic north direction and the Y
axis, around the Z axis (0 to 359). 0=North, 90=East, 180=South, 270=West" 

What you are trying to do is not use the compass
(Sensor.TYPE_ORIENTATION), but rather the raw magnetic field
(Sensor.TYPE_MAGNETIC_FIELD). *That* might need trigonometry to achieve
what you need, but I suspect the vast majority of things that need the
compass can just use the degrees supplied by the compass.

Mark Murphy (a Commons Guy)  | 

Android Consulting/App Development: 


Other Threads

1. What all do I need to begin programming in Android

> I wanted to know what all I will be needing to begin programming with

I have a Knol set up with some pointers to places to learn more about

The tutorials at, plus the (*cough*) books on Android
development, may be able to help.

Mark Murphy (a Commons Guy)
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!


2. Create custom zoom contols in Mapview


I'd like to create some custom zoom control in the mapview. I don't
know where to start.

I temporally did some stuff like this :

LinearLayout zoomView = (LinearLayout)
zoomView.setGravity(Gravity.CENTER_HORIZONTAL + Gravity.TOP);

But I'd like to create my own control with my buttons (to be coherent
with my application) or at least to remove the background ot the
standard control.

Can you please give me some clues or ways of doing. I don't know how
to be able to create the same behavior (buttons + and -)


3. AlertDialog.Builder not showing items but when there is selection by up-down key it shows

4. parse XML String...

5. web service capability

6. question about process restart management

7. incoming call broadcast intent