NFC NdefFormatable类connect()抛出IOException

Que*_*ery 6 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();
}
Run Code Online (Sandbox Code Playgroud)

当它进入try并执行connect()时,它总是抛出IOException

谁能帮我吗.