Skip to content

Fix Android 12 - FLAG_IMMUTABLE or FLAG_MUTABLE - #466

Open
SachinAgarwal1337 wants to merge 1 commit into
chariotsolutions:masterfrom
SachinAgarwal1337:patch-1
Open

Fix Android 12 - FLAG_IMMUTABLE or FLAG_MUTABLE#466
SachinAgarwal1337 wants to merge 1 commit into
chariotsolutions:masterfrom
SachinAgarwal1337:patch-1

Conversation

@SachinAgarwal1337

@SachinAgarwal1337 SachinAgarwal1337 commented Feb 23, 2022

Copy link
Copy Markdown

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
        }
    }

This PR solves the problem by just adding the requried flag which also works for lower android versions

Solve the issue I raised #465

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
        }
    }
```

This PR solves the problem by just adding the requried flag which also works for lower android versions
@SachinAgarwal1337

Copy link
Copy Markdown
Author

@don hey, by any chance can you look at this PR please? It will be very very helpful.
Thank you in advance :)

@somq

somq commented Apr 25, 2022

Copy link
Copy Markdown

I confirm this bug happens on Android 12 and hardcrashes any app with thepluging.
The attached PR fixes it.

In the meantime:
package.json

[...]
"dependencies": {
    "phonegap-nfc": "SachinAgarwal1337/phonegap-nfc#patch-1",
[...]
}

(Ping @don)

@VasanthCBH

Copy link
Copy Markdown

I am also confirming on this bug, and it is blocker for using the plugin in Android 12 + (12 or 13 beta). (Ping @don )

@MrElectroNick

Copy link
Copy Markdown

Hi @don, @krimple, @gonzalo123, @doncoleman - any updates on this?

@VasanthCBH

Copy link
Copy Markdown

Hi @don @gonzalo123 @doncoleman - Any update on this?

@adnanebrahimi

Copy link
Copy Markdown

Any Update???

@moustario moustario mentioned this pull request Dec 15, 2022
paolosanchi added a commit to paolosanchi/phonegap-nfc that referenced this pull request Dec 30, 2022
@dwettstein

Copy link
Copy Markdown

Already included in #460, thus this PR could be closed as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants