Skip to content

Commit

Permalink
Fixed IllegalStateException on RxBleAdapterStateObservable (#596)
Browse files Browse the repository at this point in the history
Setting a cancelable on an Emitter did run it immediately if it was already disposed. Postponing the setting until after the BroadcastReceiver is registered fixed the issue.
  • Loading branch information
dariuszseweryn authored Jun 28, 2019
1 parent af902c8 commit f19f46f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public void onReceive(Context context, Intent intent) {
emitter.onNext(internalState);
}
};
context.registerReceiver(receiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
emitter.setCancellable(new Cancellable() {
@Override
public void cancel() {
context.unregisterReceiver(receiver);
}
});
context.registerReceiver(receiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
}
})
.subscribeOn(Schedulers.trampoline())
Expand Down

0 comments on commit f19f46f

Please sign in to comment.