summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-03-06 22:08:49 +0100
committerGitHub <noreply@github.com>2023-03-06 22:08:49 +0100
commit6b6753ad84d42bd0cf0b7225241594b694c4f10d (patch)
tree5682865307eb8ca279475db71fd157c47917abf3 /core
parent0b3e6640570ab6b19b00a63c0880801b43c00792 (diff)
downloadAntennaPod-6b6753ad84d42bd0cf0b7225241594b694c4f10d.zip
Hide 'reconnect' settings (#6367)
Android 12+ doesn't let us start the foreground service from an event like "headset reconnected". Hide the corresponding settings and avoid crashing.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java4
2 files changed, 9 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java
index e91e24ec6..08bdd39bc 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java
@@ -37,7 +37,11 @@ public class MediaButtonReceiver extends BroadcastReceiver {
serviceIntent.putExtra(EXTRA_KEYCODE, event.getKeyCode());
serviceIntent.putExtra(EXTRA_SOURCE, event.getSource());
serviceIntent.putExtra(EXTRA_HARDWAREBUTTON, event.getEventTime() > 0 || event.getDownTime() > 0);
- ContextCompat.startForegroundService(context, serviceIntent);
+ try {
+ ContextCompat.startForegroundService(context, serviceIntent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
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 4f352aa15..92119e31e 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
@@ -1460,6 +1460,10 @@ public class PlaybackService extends MediaBrowserServiceCompat {
}
if (transientPause) {
transientPause = false;
+ if (Build.VERSION.SDK_INT >= 31) {
+ stateManager.stopService();
+ return;
+ }
if (!bluetooth && UserPreferences.isUnpauseOnHeadsetReconnect()) {
mediaPlayer.resume();
} else if (bluetooth && UserPreferences.isUnpauseOnBluetoothReconnect()) {