1

我正在开发一个在 NFC 标签中写入 NDEF 记录的 android 应用程序。我没有使用启动器来编写标签。只是将代码写入我的应用程序,我想知道如何保护标签,使其不能被重写?

这是编写记录的代码:

            Intent intent = getIntent();
    if(intent.getType() != null && intent.getType().equals(MimeType.NFC_DEMO)) {
        Parcelable[] rawMsgs = getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        NdefRecord cardRecord = msg.getRecords()[0];
        String tableName = new String(cardRecord.getPayload());
        displayCard(tableName);
    }
4

1 回答 1

1

Ndef 类有一个 makeReadOnly 方法(http://developer.android.com/reference/android/nfc/tech/Ndef.html#makeReadOnly()

要获取该对象的实例,您将使用 Ndef.get(tag)。查看高级 NFC 教程,了解如何获取标签对象 ( http://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html )

于 2013-07-02T19:59:24.790 回答