1. Check out our app, Forums for Android! Download and leave feedback here!

access compas sensor

Discussion in 'Application Development' started by ecross, Sep 23, 2010.

  1. ecross

    ecross New Member
    Thread Starter
    5

    Sep 23, 2010
    1
    0
    5
    hello all,
    i
     

    Advertisement

  2. id0001

    id0001 Well-Known Member
    38

    Apr 20, 2010
    142
    23
    38
    Student.. also software developer
    Netherlands
    step 1, get an instance of SensorManager:
    Code (Text):
    1. SensorManager manager = (SensorManager)context.getSystemService(SENSOR_SERVICE);
    step 2, get a list of sensors, in this case the TYPE_MAGNETIC_FIELD sensor:
    Code (Text):
    1. 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).
     

Share This Page

Loading...