From d5ae225070682db4b2fefc1652c7c2227dffcd9a Mon Sep 17 00:00:00 2001 From: LagradOst Date: Thu, 21 Oct 2021 23:20:13 +0200 Subject: [PATCH] crash fix for pip in android 12 --- .../cloudstream3/ui/player/PlayerFragment.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index a102d877..e2be874f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -871,12 +871,21 @@ class PlayerFragment : Fragment() { } private fun getPen(code: Int): PendingIntent { - return PendingIntent.getBroadcast( - activity, - code, - Intent("media_control").putExtra("control_type", code), - 0 - ) + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + PendingIntent.getBroadcast( + activity, + code, + Intent("media_control").putExtra("control_type", code), + PendingIntent.FLAG_IMMUTABLE + ) + } else { + PendingIntent.getBroadcast( + activity, + code, + Intent("media_control").putExtra("control_type", code), + 0 + ) + } } @SuppressLint("NewApi")