예제 #1
0
 /** Returns true if at least one Accelerometer sensor is available */
 public static boolean isSupported() {
   if (supported == null) {
     if (RosbeeRemoteActivity.getContext() != null) {
       sensorManager =
           (SensorManager)
               RosbeeRemoteActivity.getContext().getSystemService(Context.SENSOR_SERVICE);
       List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
       supported = new Boolean(sensors.size() > 0);
     } else {
       supported = Boolean.FALSE;
     }
   }
   return supported;
 }
예제 #2
0
 public static void startListening(AccelerometerListener accelerometerListener) {
   sensorManager =
       (SensorManager) RosbeeRemoteActivity.getContext().getSystemService(Context.SENSOR_SERVICE);
   List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
   if (sensors.size() > 0) {
     sensor = sensors.get(0);
     running =
         sensorManager.registerListener(
             sensorEventListener, sensor, SensorManager.SENSOR_DELAY_GAME);
     listener = accelerometerListener;
   }
 }