How to get current compass reading android 2.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 conso开发者_运维知识库le. 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
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.
精彩评论