Question

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);
    }
Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top