Make sure you have an NFC-enabled Android device or a virtual test environment—refer to the Testing your app all together recipe.
Open Eclipse and create a new Android application project named
NfcBookCh1Example1and a package named
nfcbook.ch1.example1, as shown in the following screenshot:
When prompted to create an activity, select Blank Activity.
Android requires every app to request permissions from the user to allow the application to perform restricted actions. Examples of restricted actions include access to users' current location, permission to send an SMS without user interaction permission to, read contacts, and many others. This is done in the
AndroidManifest.xml file using the
<uses-permission/> node. Permissions are granted by the user when the application is installed. Requesting unnecessary permissions may cause users to not trust the application and refrain from installation. If we do not request permissions in the manifest and try to do restricted actions, an exception is thrown and the application will not work correctly.