Locking tags
Until now, we probably used and reused the same tags to write different content types during the implementation of recipes. There is absolutely no problem with that while we are in the development stage since we need to constantly test what we are doing. In real-life usage, we may need/want to prevent tag rewrites to prevent malicious users from changing the tag content.
How to do it…
We will make some changes in the NfcHelper
class and allow the user to choose whether or not to make the tag read-only:
Open Eclipse and create a new Android application project named
NfcBookCh10Example3
and the package namednfcbook.ch10.example3
.Make sure the
AndroidManifest.xml
file is configured correctly. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.Set the minimum SDK version to 16 using the following code:
<uses-sdk android:minSdkVersion="16" />
Add the strings given in the following code to the
strings.xml
file located atres/values/
:<string...