I id0001 Well-Known Member Sep 23, 2010 #2 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).
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).