summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/service/playback/PlaybackService.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-02-14 13:24:01 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2014-02-14 13:24:01 +0100
commit65c11309801fc9ff50f8da90b9b0604b56020802 (patch)
tree31132694a739a9f304ccc3635ba7b995a8158ce9 /src/de/danoeh/antennapod/service/playback/PlaybackService.java
parent967e322913b5505029ecdcd084c058a5b286d274 (diff)
downloadAntennaPod-65c11309801fc9ff50f8da90b9b0604b56020802.zip
Resolved intent redelivery issue
Diffstat (limited to 'src/de/danoeh/antennapod/service/playback/PlaybackService.java')
-rw-r--r--src/de/danoeh/antennapod/service/playback/PlaybackService.java31
1 files changed, 19 insertions, 12 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;