如何将NFC标签格式化为NDEF格式



我有一个Mifare Classic1K NFC标签,但我无法在它上面写任何内容。它是可写的,但似乎没有在NDEF中格式化,这是Android设备写入数据的先决条件。欢迎提出任何建议。

p。S:我有一个TRF7960射频天线,如果可以帮助格式化它。

给定一个名为tagandroid.nfc.Tag对象,使用:

    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
    }

最新更新