I cannot find any tutorial on the web. How can I do it in a simple way?
A:
That of course depends on what you want your compass to show, i.e. how it is supposed to figure out the current heading.
There are at least two possible solutions:
- Use a hardware compass sensor, if the host device has one. Not sure if all Android phones have this.
- Use GPS positioning data; since GPS tracks position, you will need to have some movement to extrapolate a direction, and it will be coarse. You can't spin in place and have the compass update.
You should probably look at the LocationProvider
API, it has a method called supportsBearing()
that sounds like a good first step.
unwind
2009-11-18 09:21:44