code: public void registerSensorManager(int samplingPeriodUs) {
          if (getContext() == null || mSensorManager != null) return;
  
          // Acquires a sensor manager
          mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
  
          if (mSensorManager != null) {
              mSensorManager.registerListener(this,
                      mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR),
                      samplingPeriodUs);
          }
      }
docs: Registers a sensor manager with the parallax ImageView. Should be called in onResume
  or onStart lifecycle callbacks from an Activity or Fragment.
  
  @param samplingPeriodUs the sensor sampling period rate