• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

G1 Magnetic Detection

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ryan Waggoner
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very Cool!

Thanks a lot for the info and example
 
Ranch Hand
Posts: 140
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice code there, sure thing that Android supports all of these and hope more awesome stuff will be pushed to the SDK!
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic