I have this activity, which starts and binds to the service:
@Override
protected void onStart() {
super.onStart();
Intent intent = new Intent(context, SoundService.class);
context.startService(intent);
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
}
and I disconnect:
@Override
protected void onStop() {
context.unbindService(serviceConnection);
super.onStop();
}
The service continues to work even after the operation is closed. Take a look at this scenario:
- The action starts the service and contacts it
- Activity is killed, the service continues to work,
onUnbind()
called - The action starts again and binds to the running service.
- Activity is killed,
onUnbind()
called not : (
Why onUnbind()
not called?
source
share