diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 30eee5883b..e0c1e0da70 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,12 @@ # Release notes +### dev-v2 (not yet released) + +* UI: + * Add `PendingIntent.FLAG_IMMUTABLE` flag when creating a broadcast intent + in `PlayerNotificationManager`. This is required to avoid an error on + Android 12. + ### 2.14.1 (2021-06-11) * Core Library: diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java index 3139cd451d..6c3441a849 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java @@ -1598,8 +1598,15 @@ public class PlayerNotificationManager { String action, Context context, int instanceId) { Intent intent = new Intent(action).setPackage(context.getPackageName()); intent.putExtra(EXTRA_INSTANCE_ID, instanceId); - return PendingIntent.getBroadcast( - context, instanceId, intent, PendingIntent.FLAG_UPDATE_CURRENT); + + int pendingFlags; + if (Util.SDK_INT >= 23) { + pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; + } else { + pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT; + } + + return PendingIntent.getBroadcast(context, instanceId, intent, pendingFlags); } @SuppressWarnings("nullness:argument.type.incompatible")