Book Image

Near Field Communication with Android Cookbook

By : Vitor Subtil
Book Image

Near Field Communication with Android Cookbook

By: Vitor Subtil

Overview of this book

Table of Contents (17 chapters)
Near Field Communication with Android Cookbook
About the Author
About the Reviewers


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){...}