Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android 12 - FLAG_IMMUTABLE or FLAG_MUTABLE #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SachinAgarwal1337
Copy link

@SachinAgarwal1337 SachinAgarwal1337 commented Feb 23, 2022

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
Author

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

@somq
Copy link

somq commented Apr 25, 2022

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

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

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

@VasanthCBH
Copy link

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

@adnanebrahimi
Copy link

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

None yet

5 participants