diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-02-14 13:24:01 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-02-14 13:24:01 +0100 |
commit | 65c11309801fc9ff50f8da90b9b0604b56020802 (patch) | |
tree | 31132694a739a9f304ccc3635ba7b995a8158ce9 | |
parent | 967e322913b5505029ecdcd084c058a5b286d274 (diff) | |
download | AntennaPod-65c11309801fc9ff50f8da90b9b0604b56020802.zip |
Resolved intent redelivery issue
-rw-r--r-- | src/de/danoeh/antennapod/service/playback/PlaybackService.java | 31 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/util/playback/PlaybackController.java | 2 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java index 21aca915e..211d67532 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java @@ -127,6 +127,10 @@ public class PlaybackService extends Service { * Is true if service is running. */ public static boolean isRunning = false; + /** + * Is true if service has received a valid start command. + */ + public static boolean started = false; private static final int NOTIFICATION_ID = 1; @@ -214,6 +218,7 @@ public class PlaybackService extends Service { if (AppConfig.DEBUG) Log.d(TAG, "Service is about to be destroyed"); isRunning = false; + started = false; currentMediaType = MediaType.UNKNOWN; unregisterReceiver(headsetDisconnected); @@ -247,19 +252,21 @@ public class PlaybackService extends Service { if ((flags & Service.START_FLAG_REDELIVERY) != 0) { if (AppConfig.DEBUG) Log.d(TAG, "onStartCommand is a redelivered intent, calling stopForeground now."); stopForeground(true); - } - - if (keycode != -1) { - if (AppConfig.DEBUG) - Log.d(TAG, "Received media button event"); - handleKeycode(keycode); } else { - boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM, - true); - boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false); - boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false); - sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); - mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); + + if (keycode != -1) { + if (AppConfig.DEBUG) + Log.d(TAG, "Received media button event"); + handleKeycode(keycode); + } else { + started = true; + boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM, + true); + boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false); + boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false); + sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); + mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); + } } return Service.START_REDELIVER_INTENT; diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index 2b83bcac2..55ba4baca 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -171,7 +171,7 @@ public abstract class PlaybackController { @Override protected void onPostExecute(Intent serviceIntent) { boolean bound = false; - if (!PlaybackService.isRunning) { + if (!PlaybackService.started) { if (serviceIntent != null) { if (AppConfig.DEBUG) Log.d(TAG, "Calling start service"); activity.startService(serviceIntent); |