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

Reading a text-formatted record


In this recipe, we will see how to handle the raw payload that we get from NdefRecord and String.

Getting ready

It will be assumed that Eclipse is the development IDE and you are familiarized creating the text-formatted NdefRecords. Refer to the Writing a text-formatted record recipe in Chapter 3, Writing Tag Content.

How to do it…

This code complements the recipe where we learn how to write a string into a tag. Refer to the Writing a text-formatted record recipe in Chapter 3, Writing Tag Content.

  1. Open Eclipse and create a new Android application project named NfcBookCh5Example3 with package name nfcbook.ch5.example3.

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

  3. Import the NfcHelper class into the project and enable the foreground dispatch system.

  4. Add the following class member and instantiate it in the onCreate method:

    private NfcHelper nfcHelper;
     
    protected...