简体   繁体   English

如何锁定NFC标签?

[英]How to lock NFC tags ?

i'm developing an android application which write NDEF records in NFC tags. 我正在开发一个在NFC标签中写入NDEF记录的android应用程序。 i'm not using a launcher to write tags. 我没有使用启动器来编写标签。 just writing the code into my application and i want to know how to protect the tags so that it can't be re.written ? 只是将代码编写到我的应用程序中,我想知道如何保护标签,使其无法被重写?

and here's the code which write the record : 这是写记录的代码:

            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);
    }

The Ndef class has a makeReadOnly method ( http://developer.android.com/reference/android/nfc/tech/Ndef.html#makeReadOnly() ) Ndef类具有makeReadOnly方法( http://developer.android.com/reference/android/nfc/tech/Ndef.html#makeReadOnly()

To get an instance of that object you'll use Ndef.get(tag). 要获取该对象的实例,您将使用Ndef.get(tag)。 Take a look at the advanced NFC tutorial to see how to get the tag object ( http://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html ) 查看高级NFC教程,了解如何获取标签对象( http://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM