Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old September 23rd, 2010, 06:26 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Sep 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default access compas sensor

hello all,
im new on android and dutch so please give a extended explanation.
i've downloaded eclipse and the android skd and got it working
I made a hello world app and everything worked fine.

now I wan't to know how to access the compas sensor.
I found some explantions here but I do not understand how to use the functions in my code.

Can anybody explain or give an example?

thanks in advance,
Ecross

ecross is offline  
Reply With Quote
sponsored links
Old September 23rd, 2010, 10:57 AM   #2 (permalink)
Member
 
Join Date: Apr 2010
Location: Netherlands
Posts: 142
 
Device(s): HTC Desire
Carrier: Not Provided

Thanks: 1
Thanked 23 Times in 23 Posts
Default

step 1, get an instance of SensorManager:
Code:
SensorManager manager = (SensorManager)context.getSystemService(SENSOR_SERVICE);
step 2, get a list of sensors, in this case the TYPE_MAGNETIC_FIELD sensor:
Code:
ArrayList<Sensor> list = manager.getSensorList(Sensor.TYPE_MAGNETIC_FIELD);
step 3, check if there are any sensors in the list. If there aren't, the phone doesn't have a compas sensor.

step 4, register a SensorEventListener with the SensorManager (see the documentation for this).

step 5, experiment. (cuz I don't know what to do next since I haven't used the sensors yet).
id0001 is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:12 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.