Book Image

Near Field Communication with Android Cookbook

By : Subtil
Book Image

Near Field Communication with Android Cookbook

By: Subtil

Overview of this book

An easy-to-follow guide, full of hands-on examples of and real-world applications. Each recipe is explained and placed in context. If you want to learn how to create NFC-enabled Android applications, this is the book for you. Perhaps you already know a bit about Android application developments but have never used NFC, or perhaps you know a little about NFC android development but want some more advanced features and examples. In either case, this book will get you up and running quickly. You are expected to have Android programming knowledge.
Table of Contents (12 chapters)
11
Index

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:

  1. Open Eclipse and create a new Android application project named NfcBookCh10Example3 and the package named nfcbook.ch10.example3.

  2. Make sure the AndroidManifest.xml file is configured correctly. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.

  3. Set the minimum SDK version to 16 using the following code:

    <uses-sdk android:minSdkVersion="16" />
  4. Add the strings given in the following code to the strings.xml file located at res/values/:

    <string...