Skip to content

Commit

Permalink
Fix crash on app start on Android 12 devices
Browse files Browse the repository at this point in the history
Android 12 requires to specify mutability of the PendingIntent that is
used for the NFC intent.

Choosing a mutable PendingIntent worked out.

https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent
  • Loading branch information
marc136 committed Jan 23, 2022
1 parent 933ea62 commit d63e9a1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class NfcIntentActivity : AppCompatActivity() {
val intent = Intent(this, javaClass).apply {
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
}
pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)
pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE)
nfcAdapter = NfcAdapter.getDefaultAdapter(this)
}

Expand Down

0 comments on commit d63e9a1

Please sign in to comment.