In this recipe, we will see how to obtain several types of information regarding an NFC tag and its content.
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.
Open Eclipse and create a new Android application project named
NfcBookCh7Example1
and package namedcom.nfcbook.ch7.example1
.Make sure the
AndroidManifest.xml
file is configured correctly. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.Add the following
intent-filter
toMainActivity
:<intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter>
Add the following content to the
strings.xml
file located at/res/values
:<string name="title_activity_tag_details">Tag Details...