Home > Mobile >  Android 12: SDK(31) unable to launch activity using intents
Android 12: SDK(31) unable to launch activity using intents

Time:01-25

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)

CodePudding user response:

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.

CodePudding user response:

Just add this library in your gradle...

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

Work for me...

  •  Tags:  
  • Related