mifareClassic.authenticateSectorWithKeyA()-android.nfc.TagLostException:标记丢失

问题描述 投票:0回答:1

我遇到此异常:

android.nfc.TagLostException:标记丢失。

在android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:48)

在android.nfc.tech.BasicTagTechnology.transceive(BasicTagTechnology.java:151)

在android.nfc.tech.MifareClassic.authenticate(MifareClassic.java:395)

在android.nfc.tech.MifareClassic.authenticateSectorWithKeyA(MifareClassic.java:339)

在com.example.MyTag.a(MyTag.java:870)]中>

在com.example.MyTag.fastRead(MyTag.java:368)

这是我的代码:

Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
MifareClassic mifareClassic = MifareClassic.get(tag);
if (MY_TAG_TIMEOUT_MILLIS != -1) mifareClassic.setTimeout(MY_TAG_TIMEOUT_MILLIS); // have tried -1, 200, 500, 1000, 2000, 3000, 4000 and 5000
if (!mifareClassic.isConnected()) mifareClassic.connect();
mifareClassic.authenticateSectorWithKeyA(15, MifareClassic.KEY_DEFAULT); // This line is causing the exception

我们遇到的标签问题,我认为可能不是真正的恩智浦。

尝试过this answer的建议,但没有帮助。

已经看过MifareClassic.java source code,但是没有给我任何线索。

任何想法,潜在的问题是什么以及如何解决?

我收到此异常:android.nfc.TagLostException:标记丢失。在android.nfc.tech处的android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:48)处。]]

android nfc mifare
1个回答
0
投票

在我的情况下,出现问题是因为您需要使存储卡在范围内停留几秒钟。如果您在读完卡后将其拿走,则会出现此异常。

© www.soinside.com 2019 - 2024. All rights reserved.