O'Reilly logo

Near Field Communication with Android Cookbook by Vitor Subtil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the tag information

In this recipe, we will see how to obtain several types of information regarding an NFC tag and its content.

How to do it...

We will get the tag information through the Tag object instance, and the information regarding its content will be based on the first NdefRecord present in the tag.

  1. Open Eclipse and create a new Android application project named NfcBookCh7Example1 and package named com.nfcbook.ch7.example1.
  2. Make sure the AndroidManifest.xml file is configured correctly. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.
  3. Add the following intent-filter to MainActivity:
    <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required