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

Filtering tags by their technology

There are several types of NFC tags. They mostly differ on the storage capacity and on the communication standard used. In our application, we may want to use only a specific type of tag because of a certain characteristic of that specific tag. The Android SDK supports the most frequent tag types such as MIFARE Classic and MIFARE Ultralight tags.

How to do it...

We will create an application that is executed only when the tag technology matches the one specified by us:

  1. Open Eclipse and create a new Android application project named NfcBookCh2Example3 with the package name nfcbook.ch2.example3.

  2. Open the file, override the onNewIntent method, and insert the following code:

    protected void onNewIntent(Intent intent) {
      if ( isNfcIntent(intent) ) {
        Toast.makeText( this, "NFC intent received", Toast.LENGTH_SHORT).show();
  3. Implement the isNfcIntent method:

    boolean isNfcIntent(Intent intent) {
    return intent.hasExtra...