【发布时间】:2014-10-14 15:41:39
【问题描述】:
我在尝试擦除 NFC 标签中的数据时遇到问题。我正在使用 MifareUltralight 类型的 NFC 标签。请有人帮我找到解决方案。这是我的代码。我从here得到这个代码
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
mytag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
NdefFormatable formatable = NdefFormatable.get(mytag);
if (formatable != null) { // Here I'm getting formatable null
try {
formatable.connect();
try {
formatable.format(methodGetMsg());
} 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 {
try {
formatable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
// let the user know the tag cannot be formatted
}
【问题讨论】: