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. Using Amazons Content Delivery Network for APK distribution

I've added the ability to upload and publish via Amazons Content 
Delivery Network (CloudFront) into, so if you'd like to 
distribute your apps using CloudFront you can do so by following the 
instructions at;


Funky Android Limited is registered in England & Wales with the 
company number  6741909. The registered head office is Kemp House, 
152-160 City Road, London,  EC1V 2NX, UK. 

The views expressed in this email are those of the author and not 
necessarily those of Funky Android Limited, it's associates, or it's 


2. What are the capabilities of a Web View?

I'm in the design process of a new app, and I'm mulling over the
possibilities for the user interface. My app will need to communicate with
my web server (or a web service) for almost every interaction it has. The
app will need to occasionally send GPS information to the server, and on
rare occasions it will need to take a picture and send it to the server. Of
course, it always needs to respond to the actions of the user, and it will
need to use the information passed back from the web server (or web service)
and display the results to the user. 


So the question on my mind is how much can I rely on the web view for
interacting with the user? If Android supported ASP.NET or something
similar, then it would be possible to use the browser for almost anything I
need, and that would be very handy because it would mean that I could easily
make changes, and add new functionality by simply updating the web pages.
However from what I've seen and read so far, it seems the capabilities of
the Web View are quite limited for client side processing.


My main question is this: Is there a way to use any of the Android system
functions from a web page? If I could have an android app that has a couple
of buttons on the top and say, Location permissions, and then uses the rest
of the screen for a web browser, and the web page would be able to access
the GPS information somehow, it would be very powerful. 


Can anyone comment on this or direct me to some good information that I can
read for myself. 


Has anyone else attempted to use Web pages as the main user interface for
their apps? It would be handy to see what others have done if there are some
apps already out there.





Brad Gies




Brad Gies

27415 Greenfield Rd, # 2,

Southfield, MI, USA




Moderation in everything, including abstinence



3. error in opening file in fileexplorer application

4. How to debug(How to set breakpoint) Android source codes in Eclipse

5. Setting "Use by default for this action" option crashes when attempting to replace a standard application

6. A bit of a moral boost....

7. Android on Freerunner image and some instructions