public CoreBluetoothDetector()

in rx-central-ble/src/main/java/com/uber/rxcentralble/core/CoreBluetoothDetector.java [41:74]


  public CoreBluetoothDetector(Context context) {
    this.context = context;

    this.bluetoothStateReceiver =
        new BroadcastReceiver() {

          @Override
          public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
              int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);

              if (RxCentralLogger.isDebug()) {
                RxCentralLogger.debug("Bluetooth State Changed: " + state);
              }

              if (state == BluetoothAdapter.STATE_ON) {
                bluetoothEnabledRelay.accept(Capability.ENABLED);
              } else {
                bluetoothEnabledRelay.accept(Capability.DISABLED);
              }
            }
          }
        };

    sharedBluetoothEnabled =
        bluetoothEnabledRelay
            .hide()
            .distinctUntilChanged()
            .doOnSubscribe(disposable -> startDetection())
            .doOnDispose(() -> stopDetection())
            .replay(1)
            .refCount();
  }