From 2924955b61f9c3cc7280138a21bfa1b58448bd5c Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 12 Apr 2018 23:09:13 +0200 Subject: [PATCH] Don't pause directly after starting When registering the receiver, it immediately receives a headset unplugged event (broadcast is sticky) and pauses playback again in some cases. We are only interested in status changes, so we can just return. Fixes #2635 --- .../antennapod/core/service/playback/PlaybackService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index ab25f0a5f..67a2cdad2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -1436,6 +1436,12 @@ public class PlaybackService extends MediaBrowserServiceCompat { @Override public void onReceive(Context context, Intent intent) { + if (isInitialStickyBroadcast ()) { + // Don't pause playback after we just started, just because the receiver + // delivers the current headset state (instead of a change) + return; + } + if (TextUtils.equals(intent.getAction(), Intent.ACTION_HEADSET_PLUG)) { int state = intent.getIntExtra("state", -1); if (state != -1) {