Don't crash when the service is already disconnected and update state to allow reconnection

This commit is contained in:
Christopher Eby 2010-03-18 19:59:06 -05:00
parent adde0a4e95
commit eb88179297

View File

@ -44,6 +44,8 @@ public abstract class PlaybackServiceActivity extends Activity implements Servic
filter.addAction(PlaybackService.EVENT_CHANGED);
filter.addAction(PlaybackService.EVENT_LOADED);
registerReceiver(mReceiver, filter);
setState(PlaybackService.STATE_NORMAL);
}
@Override
@ -51,7 +53,11 @@ public abstract class PlaybackServiceActivity extends Activity implements Servic
{
super.onStop();
unbindService(this);
try {
unbindService(this);
} catch (IllegalArgumentException e) {
// we have not registered the service yet
}
try {
unregisterReceiver(mReceiver);
} catch (IllegalArgumentException e) {