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 Original file line number Diff line number Diff line change @@ -733,7 +733,7 @@ public static void logUid(String uid) {
733
733
* <li>0 - The device/tag supports MIFARE Classic</li>
734
734
* <li>-1 - Device does not support MIFARE Classic.</li>
735
735
* <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>
737
737
* <li>-4 - Wrong Intent (action is not "ACTION_TECH_DISCOVERED").</li>
738
738
* </ul>
739
739
* @see #mTag
@@ -745,10 +745,14 @@ public static int treatAsNewTag(Intent intent, Context context) {
745
745
// Check if Intent has a NFC Tag.
746
746
if (NfcAdapter .ACTION_TECH_DISCOVERED .equals (intent .getAction ())) {
747
747
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 ;
752
756
}
753
757
if (tag == null ) {
754
758
return -3 ;
You can’t perform that action at this time.
0 commit comments