我有一个Mifare Classic1K NFC标签,但我无法在上面写任何内容.它的可写但似乎没有在NDEF中格式化,这是Android设备在其上写入数据的先决条件.任何建议都是受欢迎的.
PS:我有一个TRF7960射频天线,如果它可以帮助格式化它.
给定一个android.nfc.Tag名为的对象tag来格式化它,使用:
NdefFormatable formatable=NdefFormatable.get(tag);
if (formatable != null) {
try {
formatable.connect();
try {
formatable.format(msg);
}
catch (Exception e) {
// let the user know the tag refused to format
}
}
catch (Exception e) {
// let the user know the tag refused to connect
}
finally {
formatable.close();
}
}
else {
// let the user know the tag cannot be formatted
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13125 次 |
| 最近记录: |