NFC NdefFormatable类connect()抛出IOException

时间:2014-06-12 10:05:44

标签: java android nfc

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

任何人都可以帮助我。

0 个答案:

没有答案