我正在尝试使Android应用程序写NFC标签。要看到如何做到这一点,我已经下载了一个例子。但是,该示例不起作用。它说它无法验证。这只能表示它对这种类型的卡使用了不正确的密钥。奇怪的是,即使是KEY_DEFAULT
和KEY_MIFARE_APPLICATION_DIRECTORY
键也无法在我的空白卡上工作。 Mifare是否以任何方式更换了钥匙?Mifare Classic 1k写钥匙
编辑:这是我的代码。
/* 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
都无济于事..
参阅本博客:http://nearfieldcommunication.com/developers/android/ http://mifareclassicdetectiononandroid.blogspot.jp/2011/04/reading-mifare-classic- 1k-from-android.html希望这将有助于您了解Google理解 –