Code example for SensorManager

Methods: getSensorListregisterListener

0
        } 
 
        this.setStatus(AccelListener.STARTING);
 
        // Get accelerometer from sensor manager 
        List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
 
        // If found, then register as listener 
        if ((list != null) && (list.size() > 0)) {
          this.mSensor = list.get(0);
          this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI);
          this.setStatus(AccelListener.STARTING);
        } else { 
          this.setStatus(AccelListener.ERROR_FAILED_TO_START);
          this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
          return this.status;
        } 
 
        // Set a timeout callback on the main thread. 
        Handler handler = new Handler(Looper.getMainLooper());
        handler.postDelayed(new Runnable() {