简体   繁体   中英

How to lock NFC tags ?

i'm developing an android application which write NDEF records in NFC tags. 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() )

To get an instance of that object you'll use 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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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