4

Hey I am getting warning for pending intent. So I surrounded for check of checking sdk according to this question and this medium post. I am getting warning message Missing PendingIntent mutability flag

val pendingIntent: PendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
            } else {
                PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
            }

enter image description here

How can I remove this warning messgae?

enter image description here

vivek modi
  • 880
  • 1
  • 8
  • 26

1 Answers1

0

Add pending intent like this

val updatedPendingIntent = PendingIntent.getActivity(
applicationContext,
NOTIFICATION_REQUEST_CODE,
updatedIntent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT )

If the error still remains and your targetSdkVersion = 31 then the error must caused because one of your dependencies is internally using WorkManager or your are directly using old version of WorkManager. To solve simply add this dependency

implementation 'androidx.work:work-runtime-ktx:2.7.0'
Muhammad Asad
  • 583
  • 4
  • 8