Skip to content

Commit

Permalink
Tried to fix other strange crash on some devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarus23 committed May 4, 2024
1 parent dafdb26 commit 8375c4b
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public static void logUid(String uid) {
* <li>0 - The device/tag supports MIFARE Classic</li>
* <li>-1 - Device does not support MIFARE Classic.</li>
* <li>-2 - Tag does not support MIFARE Classic.</li>
* <li>-3 - Error (tag or context is null).</li>
* <li>-3 - Error (tag or context is null or dead object).</li>
* <li>-4 - Wrong Intent (action is not "ACTION_TECH_DISCOVERED").</li>
* </ul>
* @see #mTag
Expand All @@ -745,10 +745,14 @@ public static int treatAsNewTag(Intent intent, Context context) {
// Check if Intent has a NFC Tag.
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
Tag tag;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
} else {
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
try {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
} else {
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
} catch (RuntimeException ex) {
return -3;
}
if (tag == null) {
return -3;
Expand Down

0 comments on commit 8375c4b

Please sign in to comment.