Discussion in 'Application Development' started by ecross, Sep 23, 2010.
step 1, get an instance of SensorManager:
SensorManager manager = (SensorManager)context.getSystemService(SENSOR_SERVICE);
step 2, get a list of sensors, in this case the TYPE_MAGNETIC_FIELD sensor:
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).