We have a scenario, where in we switch off the BLE Enabled device and then the Android App screen shall grey out. But when the switch off the BLE Enabled device, instead of Greying out, the screen remains freezes and UI does not respond
None of the methods like onNext(), onCompleted() and onError() in the subscriber are called after executing the Observable.
below is the Subscriber code:
private void subscribeToConnEvents() {
Subscriber<ConnService.ConnEvent> subscriber = new Subscriber<ConnService.ConnEvent>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(ConnService.ConnEvent connEvent) {
}
};
SerializedSubscriber<ConnService.ConnEvent> serializedSubscriber = new SerializedSubscriber<>(subscriber);
}
Below is the Observable code from which the subscriber shall be called:
In the Below Code the connectionStateSubject gets initialised in the Constructor
private SerializedSubject<ConnEvent, ConnEvent> connectionStateSubject;
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
BluetoothDevice device = gatt.getDevice();
String address = gatt.getDevice().getAddress();
ConnectionEvent event = new ConnectionEvent();
event.deviceAddress = address;
if (newState == BluetoothProfile.STATE_DISCONNECTED) {
event.status = ConnectionStatus.STATE_DISCONNECTED;
connectionStateSubject.onNext(event);
}
}