[Android mdslib-1.38.0] leaked IntentReceiver com.polidea.rxandroidble.RxBleAdapterStateObservable

Issue #88 closed
Martin Tiefengrabner created an issue

I’m connecting and subscribing to multiple Meas-Endpoints using a foreground service in Android. Connecting and subscribing works fine but when I close my Service I receive an error about leaking an registered IntentReceiver:

Service [myServiceName] has leaked IntentReceiver com.polidea.rxandroidble.RxBleAdapterStateObservable$1$1@eab2aaa that was originally registered here. Are you missing a call to unregisterReceiver()?

Before calling stopSelf() of the Service I’m disconnecting all devices by running:

for (int i = MovesenseConnectedDevices.getRxMovesenseConnectedDevices().size() - 1; i >= 0; i--) {
    RxBleDevice md = MovesenseConnectedDevices.getConnectedRxDevice(i);
    BleManager.INSTANCE.disconnect(md);
    MovesenseConnectedDevices.removeRxConnectedDevice(md);
}

for (int i = MovesenseConnectedDevices.getConnectedDevices().size() - 1; i >= 0; i--) {
    MovesenseDevice md = MovesenseConnectedDevices.getConnectedDevice(i);
    MovesenseConnectedDevices.removeConnectedDevice(md);
}

for (SensorDevice sensor : this.sensors) {
    getMds().disconnect(sensor.getMacAddress());
}

for (MdsSubscription subscription : subscriptions) {
    subscription.unsubscribe();
}

When I restart the Service MdsConnectionListener of the shutdown service is still called.

Update:

I managed to get rid of the error about the leaked IntentReceiver by waiting until onDisconnect() was called for all connected devices. But MdsConnectionListener of the stopped Instance of my ForegroundService is still called when I restart the ForegroundService

Comments (4)

  1. Log in to comment