Activity <App Name> has leaked ServiceConnection <ServiceConnection Name>@438030a8 that was originally bound here
You haven't provided any of your code from LightFactoryRemote
, so this is only a presumption, but it looks like the kind of problem you'd be seeing if you were using the bindService
method on it's own.
To ensure a service is kept running, even after the activity that started it has had its onDestroy
method called, you should first use startService
.
The android docs for startService state:
Using startService() overrides the default service lifetime that is managed by bindService(Intent, ServiceConnection, int): it requires the service to remain running until stopService(Intent) is called, regardless of whether any clients are connected to it.
Whereas for bindService:
The service will be considered required by the system only for as long as the calling context exists. For example, if this Context is an Activity that is stopped, the service will not be required to continue running until the Activity is resumed.
So what's happened is the activity that bound (and therefore started) the service, has been stopped and thus the system thinks the service is no longer required and causes that error (and then probably stops the service).
Example
In this example the service should be kept running regardless of whether the calling activity is running.
ComponentName myService = startService(new Intent(this, myClass.class));
bindService(new Intent(this, myClass.class), myServiceConn, BIND_AUTO_CREATE);
The first line starts the service, and the second binds it to the activity.
You can use:
@Override
public void onDestroy() {
super.onDestroy();
if (mServiceConn != null) {
unbindService(mServiceConn);
}
}