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.
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.
Open Eclipse and create a new Android application project named
NfcBookCh5Example4
with package namenfcbook.ch5.example4
.Make sure that 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 the
NfcHelper
class into the project and enable the foreground...