Near field communications (NFC) is an interesting technology that is built into most modern smartphones. Recently I read an article outlining how to read NFC tags on Android. The article did a good job at giving a basic overview of the implementation, but using the steps described left me with some questions and for my use case it did not work.
I was recently tasked with creating an Android application to read data from Near Field Communication tags. In the process of understanding this technology’s history, standards, and then actually writing the app, I spent a large chunk of time digging through old documentation, out of date web tutorials, and unanswered Stack Overflow questions. In the spirit of Larry Wall’s Three Virtues, I’ve created this primer as a condensed explanation and implementation for those looking to add Near Field Communication tag reading to their own Android project.
“When all else fails, read the instructions.”
Like Bluetooth, Wifi, and other forms of wireless signals, Near Field Communication (NFC) is a communication technology based around the idea of transmitting data over radio waves. NFC uses the same type of technology found in other products, such as mobile payment systems, RFID cards, and electronic key fobs. The main advantage of NFC over these other forms of wireless communications is its ability to store and transmit small amounts of information between a passive, unpowered storage system and an external, powered reader. And it can transmit data without having to pair devices traditionally, like with Bluetooth or Wifi. An NFC storage device can be something as small as a sticker, coin, business card, or bracelet. Additionally, most Android phones come with a built-in NFC reader. So let’s get to the good stuff.
An Android device with NFC support
(optional) NFC tags