我正在尝试制作一个Android应用程序来编写NFC标签。为了了解如何做到这一点,我下载了一个示例。但是,该示例不起作用。它说它不能认证。这只能意味着它对这种类型的卡使用了不正确的密钥。奇怪的是,即使是KEY_DEFAULT和KEY_MIFARE_APPLICATION_DIRECTORY键也不能在我的空白卡上工作。Mifare是否以任何方式更改了密钥?
编辑:这是我的代码。
/* Authenticate the MAD Sector, sector 1, with key A */
succes = mClassic.authenticateSectorWithKeyA(
1, key);
if (succes) {
/* Authentication succeeded */
/*
* This will read a 16-byte block in this sector
* It is an I/O operation and will block until complete.
* It must not be called from the main application thread.
**/
b.append(mClassic.readBlock(1), 0, 16);
b.append(mClassic.readBlock(2), 0, 16);
b.append(mClassic.readBlock(3), 0, 16);
data = b.toByteArray();
}
/* Authentication failed */
else
sb.append("Authentication failed");
mClassic.close();
}我已经用下面的键尝试过了:
MifareClassic.KEY_DEFAULT
MifareClassic.KEY_MIFARE_APPLICATION_DIRECTORY
00 00 00 00 00 00
ff ff ff ff ff ff一切都无济于事..
发布于 2012-09-24 22:53:23
我不熟悉Ubiqconn Tablet PC。我要做的第一件事是检查设备中的NFC实现是否真正支持MIFARE。在主要活动的onCreate()中添加:
public void onCreate(Bundle bundle) {
...
if (!getPackageManager().hasSystemFeature("com.nxp.mifare")) {
Toast.makeText(this, "No MIFARE support!", Toast.LENGTH_LONG).show();
}
}发布于 2012-09-24 17:11:37
您的应用程序中存在错误,或者密钥已被自定义。使用像NFC TagInfo这样的应用程序来检查您是否可以使用默认密钥读/写卡。如果不起作用,联系卖给你卡片的人,问他们钥匙是什么。
https://stackoverflow.com/questions/12561882
复制相似问题