我正在嘗試使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理解 –