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
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.
Just add this library in your gradle…
Work for me…