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

Reading custom mimes


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.

How to do it…

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:

  1. Open Eclipse and create a new Android application project named NfcBookCh5Example6 with package name com.nfcbook.ch5.example6.

  2. Make sure the AndroidManifest.xml file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.

  3. Set the minimum required version to API level 16.

  4. Import MyClass from the Working with custom mimes recipe in Chapter 3, Writing Tag Content.

  5. Import the NfcHelper class into the project and enable the foreground dispatch system.

  6. Add the following class member and instantiate it in the onCreate method:

    private NfcHelper nfcHelper;
    
    protected void onCreate(Bundle savedInstanceState...