当我想格式化unformatted
标记时,我遇到了类似的问题。我在Android 6中。我在Android 4.4中有一个专有设备,相同的代码运行良好。这是我使用的代码,我发给我标签的信息。
public static void writeToTag(Tag paramTag, final NdefMessage paramNdefMessage) throws Exception
{
List localList = Arrays.asList(paramTag.getTechList());
if (localList.contains(NFC_TECH_NDEF)) {
Ndef localNdef = Ndef.get(paramTag);
localNdef.connect();
if (localNdef.getMaxSize() < paramNdefMessage.toByteArray().length) {
throw new E_TagTooSmallException();
}
localNdef.writeNdefMessage(paramNdefMessage);
localNdef.close();
return;
}
if (localList.contains(NFCTECH_NDEF_FORMATTABLE)) { //my Tag is NDefFormatable
NdefFormatable localNdefFormatable = NdefFormatable.get(paramTag);
localNdefFormatable.connect(); // OK
try {
localNdefFormatable.format(paramNdefMessage); //IO Exception here
} finally {
localNdefFormatable.close();
}
return;
}
throw new Exception("Tag is unsupported");
}
感谢您的帮助!!