question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 12 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

See original GitHub issue

The plugin works perfectly in all devices except for Andorid 12. I get following error

 Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

I see the problem is in createPendingIntent Method

 private void createPendingIntent() {
        if (pendingIntent == null) {
            Activity activity = getActivity();
            Intent intent = new Intent(activity, activity.getClass());
            intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0); // Problem in the last param here
        }
    }

Would like to know if I am doing something wrong? or is this needs to be fixed

P.S I use this plugin for only reading NFC tags

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:25

github_iconTop GitHub Comments

2reactions
dilo99commented, Jul 21, 2022

@escully27 > OK thanks. Let me know if helpful I can change mine otherwise probably best to do a PR for yours

ok i created a PR, I don’t know how useful it is, there are another 15 waiting for more than two years …

1reaction
dilo99commented, Jul 21, 2022

i fixed this on my fork: https://github.com/dilo99/phonegap-nfc

Read more comments on GitHub >

github_iconTop Results From Across the Web

MediaSessionCompat:Targeting S+ (version 31 and above ...
If your app targets Android 12, you must specify the mutability of each PendingIntent object that your app creates.
Read more >
Android 12 run: Fatal Exception Targeting S+ (version 31 and ...
Android 12 run: Fatal Exception Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE.
Read more >
Targeting S+ (version 31 and above) requires that one of ...
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Read more >
Runtime Error: Targeting S+ (version 31 and above) requires ...
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly ...
Read more >
PendingIntent - Android Developers
S , it will be required to explicitly specify the mutability of PendingIntents on creation with either (@link #FLAG_IMMUTABLE} or FLAG_MUTABLE .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found