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
This commit is contained in:
ByteHamster 2018-04-12 23:09:13 +02:00
parent 4e63bfb11c
commit 2924955b61
1 changed files with 6 additions and 0 deletions

View File

@ -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) {