我写&阅读Android 4.4.4下的Ultralight C NFC芯片。
MifareUltralight mifare = MifareUltralight.get(tag);
JSONObject result = new JSONObject();
try {
mifare.connect();
authenticate(tag, mifare);
Log.d(TAG, "authenticate successful");
int flag = 0;
String message = "";
int nbByte = 0;
for(int page = 4; page < 39; page++) {
byte[] cmd = {0x30, (byte) page};
byte[] msg = mifare.transceive(cmd);
// Misc...
}
} catch (IOException e) {
Log.e(TAG, "IOException while reading MifareUltralight message...", e);
return null;
} catch (JSONException e) {
e.printStackTrace();
return null;
} finally {
if (mifare != null) {
try {
mifare.close();
}
catch (IOException e) {
Log.e(TAG, "Error closing tag...", e);
}
}
}
问题:如果代码被锁定,身份验证就会很好然后此脚本会从
中引发java.io.IOException: transceive failed
异常
记录验证成功。