Skip to content

Commit 3ed25a5

Browse files
committed
Android 12 PendingIntent Fix #477
1 parent 617c7ba commit 3ed25a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,13 @@ private void createPendingIntent() {
492492
Activity activity = getActivity();
493493
Intent intent = new Intent(activity, activity.getClass());
494494
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
495-
pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
495+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
496+
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
497+
pendingIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_MUTABLE);
498+
} else {
499+
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
500+
pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
501+
}
496502
}
497503
}
498504

0 commit comments

Comments
 (0)