In this recipe, we will see how we can identify tags formatted with our custom mime and how to convert the raw data into an object instance.
The code complements the recipe where we learn how to write a URI into a tag. Refer to the Working with custom mimes recipe in Chapter 3, Writing Tag Content. Perform the following steps:
Open Eclipse and create a new Android application project named
NfcBookCh5Example6
with package namecom.nfcbook.ch5.example6
.Make sure the
AndroidManifest.xml
file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.Set the minimum required version to API level 16.
Import
MyClass
from the Working with custom mimes recipe in Chapter 3, Writing Tag Content.Import the
NfcHelper
class into the project and enable the foreground dispatch system.Add the following class member and instantiate it in the
onCreate
method:private NfcHelper nfcHelper; protected void onCreate(Bundle savedInstanceState...