NdefFormatable ndefFormatable = NdefFormatable.get(tag);
if (ndefFormatable == null) {
throw new TagException("Not a NDEF formatable tag");
}
try {
if(!ndefFormatable.isConnected())
{
ndefFormatable.connect();
}
tagData.setUniqueId(tag.getId());
NdefMessage ndefMessage = buildNdefMessage(tagData);
ndefFormatable.format(ndefMessage);
}
catch (FormatException ex) {
throw new TagException(ex.getMessage());
}
finally {
ndefFormatable.close();
}
当它进入try并执行connect()时,它总是抛出IOException
任何人都可以帮助我。