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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding the tag dispatch system


The Android system has a structured way to deal with the different tag types, technologies, and content. In this recipe, we will create a simple app that will allow us to visualize the implemented structure.

How to do it...

By performing the following steps, we are going to create an application that will allow us to see the triggered action when we tag different tags in our device:

  1. Open the MainActivity.java file from the previously created NfcBookCh2Example1 project.

  2. On the onNewIntent method, add the following lines of code:

    String action = intent.getAction();
    Toast.makeText(this, action, Toast.LENGTH_SHORT).show();
    
  3. Open the NFC Simulator tool and simulate a few taps for different tag types and then see the results.

    In the NFC Simulator tool, when tag names end with _LOCKED, it means that the tags are formatted and have content on them; probably, an NDEF record. Therefore, the NDEF_DISCOVERED action will be triggered. Unformatted tags will trigger the...