skip to Main Content

This is the code –

if (Build.VERSION.SDK_INT >= 31) {
            Intent intent=new Intent(launcher.this,MainActivity.class);
            startActivity(intent);
            finish();
        }

I am getting this error-
Console error-

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)

2

Answers


  1. Pending intent mutability flag error isn’t necessarily where the stacktrace was thrown(from experience), try to search the project of any of your code uses pending intents without setting the mutability flag.

    Login or Signup to reply.
  2. Just add this library in your gradle…

    implementation 'androidx.work:work-runtime-ktx:2.7.0-alpha05'
    

    Work for me…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search