The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/android_common: Specify mutability flag for PendingIntent object.

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or
FLAG_MUTABLE to be specified when creating a PendingIntent, according to
https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent.

authored by

dengkail and committed by
Jakob Bornecrantz
a809635f 0921f01e

+7 -7
+7 -7
src/xrt/targets/android_common/src/main/java/org/freedesktop/monado/android_common/RestartRuntimeDialogFragment.kt
··· 13 13 import android.content.Context 14 14 import android.content.DialogInterface 15 15 import android.content.Intent 16 + import android.os.Build 16 17 import android.os.Bundle 17 18 import android.os.Process 18 19 import androidx.appcompat.app.AlertDialog ··· 36 37 37 38 private fun delayRestart(delayMillis: Long) { 38 39 val intent = Intent(requireContext(), AboutActivity::class.java) 39 - val pendingIntent = 40 - PendingIntent.getActivity( 41 - requireContext(), 42 - REQUEST_CODE, 43 - intent, 44 - PendingIntent.FLAG_CANCEL_CURRENT 45 - ) 40 + var flags = PendingIntent.FLAG_CANCEL_CURRENT 41 + // From targeting S+, the PendingIntent needs one of FLAG_IMMUTABLE and FLAG_MUTABLE 42 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 43 + flags = flags or PendingIntent.FLAG_IMMUTABLE 44 + } 45 + val pendingIntent = PendingIntent.getActivity(requireContext(), REQUEST_CODE, intent, flags) 46 46 val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager 47 47 am.setExact(AlarmManager.RTC, System.currentTimeMillis() + delayMillis, pendingIntent) 48 48 }