问题
I've a Mifare Classic1K NFC tag but I'm unable to write any content over it. Its writable but seems like it is not formatted in NDEF which is a pre-requisite for Android devices to be write data on it. Any suggestion is welcome.
P.S: I do have a TRF7960 RF Antenna if that can help to format it.
回答1:
Given an android.nfc.Tag
object named tag
, to format it, use:
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
}
来源:https://stackoverflow.com/questions/13970931/how-to-format-an-nfc-tag-in-ndef-format