code: public Flowable<ReactiveSensorEvent> observeSensor(int sensorType, final int samplingPeriodInUs,
        final Handler handler, final BackpressureStrategy strategy) {
  
      if (!hasSensor(sensorType)) {
        String format = "Sensor with id = %d is not available on this device";
        String message = String.format(Locale.getDefault(), format, sensorType);
        return Flowable.error(new SensorNotFoundException(message));
      }
  
      final Sensor sensor = sensorManager.getDefaultSensor(sensorType);
      final SensorEventListenerWrapper wrapper = new SensorEventListenerWrapper();
      final SensorEventListener listener = wrapper.create();
  
      return Flowable.create(new FlowableOnSubscribe<ReactiveSensorEvent>() {
        @Override public void subscribe(final FlowableEmitter<ReactiveSensorEvent> emitter)
            throws Exception {
  
          wrapper.setEmitter(emitter);
  
          if (handler == null) {
            sensorManager.registerListener(listener, sensor, samplingPeriodInUs);
          } else {
            sensorManager.registerListener(listener, sensor, samplingPeriodInUs, handler);
          }
        }
      }, strategy).doOnCancel(new Action() {
        @Override public void run() throws Exception {
          sensorManager.unregisterListener(listener);
        }
      });
    }
docs: Returns RxJava Observable, which allows to monitor hardware sensors
  as a stream of ReactiveSensorEvent object with defined sampling period
  
  @param sensorType sensor type from Sensor class from Android SDK
  @param samplingPeriodInUs sampling period in microseconds,
  @param handler the Handler the sensor events will be delivered to, use default if it is null
  you can use predefined values from SensorManager class with prefix SENSOR_DELAY
  @param strategy BackpressureStrategy for RxJava 2 Flowable type
  @return RxJava Observable with ReactiveSensorEvent