Ryan Waggoner wrote:Hey guys,
This post might be too much about the G1 but...
I still get excited when I find out the phone can still do cool things. For example the compass works with real magnetic fields. I was wondering where i could find information to see how this works, and how to harness the data...
Just to play with it really
Thanks!
Hi Ryan,
You would need to use
android.hardware.SensorManager class and
android.hardware.SensorListener interface to read magnetic values.
Start with the Compass example (via this
link copy-pasted here for your convenience):
You would need to change this particular example (line 69) to read magnetic field data instead of orientation data:
Continue experimenting from there in the vicinity of sources of magnetic fields in your house - other mobile phones, TV, microwave (but don't put your Android inside!) etc.
I hope that helps.
BTW, did you know Android SDK developers even made it easier for you to develop a Star Wars games.
There's a constant is in SDK:
android.hardware.SensorManager.GRAVITY_DEATH_STAR_I :-)
Cheers!
Shonzilla