I have a service that stores a Messenger as a member variable and returns messenger.getBinder() on onBind(Intent). I am connecting to this service with:
void Bind()
{
Intent intent = new Intent("com.example.RemoteBindingService");
bindService(intent, mServiceConnection,
Context.BIND_AUTO_CREATE); // Context.BIND_AUTO_CREATE
// means
// "start if not started"
mBound = true;
}
Before calling Bind(), sending a Message to the service does nothing. After calling Bind(), sending a Message to the service works correctly. However, I would expect that after calling
void Unbind()
{
if(mBound == true)
{
unbindService(mServiceConnection);
mBound = false;
}
}
that sending a Message to the service would again do nothing. However, this is not the case - the service keeps working. Can anyone explain how to properly disconnect from a service?