Chapter 6. An NFC Application in Practice

So far you’ve gotten an understanding of the differences between NFC and NDEF and an introduction to NDEF messages and records. You’ve also seen how Android’s tag dispatch system can work in either the foreground or the background to filter tags by type and take action where appropriate. In this chapter, you’ll use what you’ve learned to make a full application that can control the lights and music in your home from your mobile device. The application you’re going to build is a classic. It’s been done in so many forms and shown at so many tech conferences that it’s a cliché by now. We’ll call it the “Mood Setter” application.

The premise of the application is simple: you might want a different ambiance in your home for the various activities you do there. When you’re cleaning the house, you probably want the lights nice and bright, and some cheery music on to keep you moving. When you’re working at your desk concentrating, you might like quieter music, maybe something without words to distract you, and you don’t need the whole place lit, just where you’re working. At dinnertime, perhaps you want want a nice warm glow around the table and some soothing music in the background. Or perhaps you’re just having a relaxing evening and want the lights down low and a little Barry White on the hi-fi. Who can resist that?

To make all that happen, you’ll write the settings to NFC tags that are scattered around the house, and then use your device to read ...

Get Beginning NFC now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.