Commit 4518cdae authored by Sébastien Toque's avatar Sébastien Toque
Browse files

bind/unbind properly from the service

parent 554878f0
......@@ -124,7 +124,7 @@ public class AudioServiceController implements AudioPlayerControl {
}
context = context.getApplicationContext();
if (mAudioServiceBinder == null) {
if (!mIsBound) {
Intent service = new Intent(context, AudioService.class);
context.startService(service);
mIsBound = context.bindService(service, mAudioServiceConnection, Context.BIND_AUTO_CREATE);
......@@ -145,17 +145,15 @@ public class AudioServiceController implements AudioPlayerControl {
}
context = context.getApplicationContext();
if (mAudioServiceBinder != null) {
if (mIsBound) {
try {
mAudioServiceBinder.removeAudioCallback(mCallback);
if (mIsBound) {
context.unbindService(mAudioServiceConnection);
mIsBound = false;
}
} catch (RemoteException e) {
Log.e(TAG, "remote procedure call failed: removeAudioCallback()");
}
context.unbindService(mAudioServiceConnection);
mIsBound = false;
mAudioServiceBinder = null;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment