5

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

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

4

1 回答 1

7

给定一个android.nfc.Tag名为 的对象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
    }
于 2012-12-20T12:05:40.080 回答