aspose file tools*
The moose likes Android and the fly likes G1 Magnetic Detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "G1 Magnetic Detection" Watch "G1 Magnetic Detection" New topic
Author

G1 Magnetic Detection

Ryan Waggoner
Ranch Hand

Joined: Jun 27, 2007
Posts: 75
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!
Jake Reynolds
Greenhorn

Joined: Mar 10, 2009
Posts: 12
Wow, that's cool! Anyone know of it's subject to the same acceleration and turning errors a wet compass is? I've got to get my hands on a G1 to test it out.


--Jake
Nenad Nikolic
Greenhorn

Joined: Mar 20, 2009
Posts: 13
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
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

The API(SensorManager) class has constants for 11 different sensors(If i remember correctly). Accelerometer, Orientation Sensor, Temperature sensor, Magnetic sensor etc.
Different devices will support(or will be built with) different sensors, I think. It surely sounds cool.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Ryan Waggoner
Ranch Hand

Joined: Jun 27, 2007
Posts: 75
Very Cool!

Thanks a lot for the info and example
Michael Rivera
Ranch Hand

Joined: Dec 31, 2007
Posts: 121

Nice code there, sure thing that Android supports all of these and hope more awesome stuff will be pushed to the SDK!


So many things to do so little time !!!
@mikedroid myLinkedIn
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: G1 Magnetic Detection