Book Image

Near Field Communication with Android Cookbook

By : Subtil
Book Image

Near Field Communication with Android Cookbook

By: Subtil

Overview of this book

An easy-to-follow guide, full of hands-on examples of and real-world applications. Each recipe is explained and placed in context. If you want to learn how to create NFC-enabled Android applications, this is the book for you. Perhaps you already know a bit about Android application developments but have never used NFC, or perhaps you know a little about NFC android development but want some more advanced features and examples. In either case, this book will get you up and running quickly. You are expected to have Android programming knowledge.
Table of Contents (12 chapters)
11
Index

Handling tag-writing errors


In this recipe, we will modify the NfcHelper write methods to throw both custom and native exceptions to allow us to correctly identify what went wrong during the write operation. This will make our applications more bulletproof and user friendly.

Getting ready

The following settings need to be configured for the recipe:

  • Make sure you have a working Android development environment. If you don't, ADT Bundle is a good kit to start with (http://developer.android.com/sdk/index.html).

  • Make sure you have NFC-enabled Android device or a virtual test environment. Refer to the Testing your app all together recipe in Chapter 1, Getting Started with NFC.

  • It will be assumed that Eclipse is the development IDE.

How to do it...

In this application, we will be tweaking the writeNdefMessage and formatTag methods we have used so far in the book. We will use the code files from the Leaving a (small) note – Part 2 recipe of Chapter 6, Reading Tag Content – Real-life Examples, to perform...