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

Introduction


In this chapter, we will create some applications that are actually used in real-life scenarios. We can use them on a daily basis to simplify repetitive tasks.

For simplicity purposes, the methods related to tags and NDEF Records handling, which we used in Chapter 2, Detecting a Tag, and Chapter 3, Writing Tag Content, were placed in the NfcHelper class. This class will to be used in every Android-related recipe and is described in the following code:

public class NfcHelper {
  public NfcHelper(Activity activity){...}

  public boolean isNfcEnabledDevice(){...}

  public boolean isNfcIntent(Intent intent){...}

  public Tag getTagFromIntent(Intent intent){...}

  public void enableForegroundDispatch(){...}

  public void disableForegroundDispatch(){...}

  public boolean writeNdefMessage(Intent intent, NdefMessage ndefMessage){...}

  public boolean writeNdefMessage(Tag tag, NdefMessage ndefMessage){...}

  private boolean formatTag(Tag tag, NdefMessage ndefMessage){...}

  public...