Skip to content

Commit 8375c4b

Browse files
committed
Tried to fix other strange crash on some devices.
1 parent dafdb26 commit 8375c4b

File tree

1 file changed

+9
-5
lines changed
  • Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool

1 file changed

+9
-5
lines changed

Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Common.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ public static void logUid(String uid) {
733733
* <li>0 - The device/tag supports MIFARE Classic</li>
734734
* <li>-1 - Device does not support MIFARE Classic.</li>
735735
* <li>-2 - Tag does not support MIFARE Classic.</li>
736-
* <li>-3 - Error (tag or context is null).</li>
736+
* <li>-3 - Error (tag or context is null or dead object).</li>
737737
* <li>-4 - Wrong Intent (action is not "ACTION_TECH_DISCOVERED").</li>
738738
* </ul>
739739
* @see #mTag
@@ -745,10 +745,14 @@ public static int treatAsNewTag(Intent intent, Context context) {
745745
// Check if Intent has a NFC Tag.
746746
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
747747
Tag tag;
748-
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
749-
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
750-
} else {
751-
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
748+
try {
749+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
750+
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag.class);
751+
} else {
752+
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
753+
}
754+
} catch (RuntimeException ex) {
755+
return -3;
752756
}
753757
if (tag == null) {
754758
return -3;

0 commit comments

Comments
 (0)