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 a URI-formatted record


In this recipe, we will see how to obtain a URI from the NDEF record, although the Android system autoprocesses the web URI, and then passes it to the registered URL schemes application. As seen in the Filtering URI tags recipe in Chapter 2, Detecting a Tag, we can define which URI tags are sent to our application so that we can obtain the URL from the tag, perform something with it, and prevent the default action.

How to do it…

This code complements the Writing a URI-formatted record recipe in Chapter 3, Writing Tag Content, where we learned how to write a URI into a tag.

  1. Open Eclipse and create a new Android application project named NfcBookCh5Example4 with package name nfcbook.ch5.example4.

  2. Make sure that 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 the NfcHelper class into the project and enable the foreground...