tags:

views:

288

answers:

1

How do I get the current compass reading in android 2.1? I know that I can initiate a listener and receive updates but I do not need constant updates I only need it to get the compass orientation when the user clicks a button.

Also what is the most accurate way to get the compass orientation?

Lastly, how do I send fake data to the android console. I know that you're supposed to use the terminal and send it commands but what are the commands I can't seem to find it on the Android website.

Thank you

+1  A: 

Unfortunately, it is not currently possible to do what you want. You will need to register a listener to get the sensor values and unregister it once you get your first update.

Since you can't send fake sensor values to the emulator like you can for GPS, I suggest you check out the OpenIntents Sensor Simulator. It isn't as nice as having the functionality built into the emulator and goldfish platform code but it does at least provide a way to test applications that use sensors without actually having hardware.

Tim Kryger
Thanks so much for the quick reply. I think that's exactly the path I will take. Do you know what is the most accurate method to get your direction? Should I use TYPE_ORIENTATION or should I use something like the accelerometer?
Brandon Delany
Depending upon your application you might want to read the magnetic field and acceleration sensors to calculate the orientation since it could offer better accuracy but given that it is more work, reading the orientation sensor may be sufficient.
Tim Kryger
For some reason I can't find the current OpenIntents binary file. They're all deprecated. And I can't find how to install it.
Brandon Delany
Not sure but [this](http://code.google.com/p/openintents/wiki/SensorSimulator) may be a better link.
Tim Kryger
Yea I got the link but there is no where to download the binary file..
Brandon Delany