Use pending intent flag for Android 12 - #2
Open
tylervz wants to merge 6 commits into
Open
Conversation
|
@tylervz I am glad my PR helped you out. I have tested my own changes on a physical Samsung Galaxy S21 running Android 12 and I am able to scan NFC tags inside my app. I don't have a demo I can show you at the moment because the app I applied this fix to, belongs to the company I work for. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix app crashes on Android 12 and above. Android 12 is known to crash on launch if the Intent flag is not explicitly set to MUTABLE or IMMUTABLE.
My work is copied from this PR:
chariotsolutions#477
The MUTABLE flag is used which is the default flag for a PendingIntent activity.
https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE
"Up until Build.VERSION_CODES.R, PendingIntents are assumed to be mutable by default, unless FLAG_IMMUTABLE is set. Starting with Build.VERSION_CODES.S, it will be required to explicitly specify the mutability of PendingIntents on creation with either FLAG_IMMUTABLE or FLAG_MUTABLE"
I do not have a physical device running Android 12 so I can't personally confirm that reading NFC tags works with these changes. My app is no longer crashing with this branch on the Android 12 emulator.