When I first got my Google Cardboard toolkit – in my case the DODOcase VR Toolkit V1 – I was fascinated by the NFC tag that came with it. I hadn’t really played with NFC, prior to that, and only had a very vague idea of what it was about.
It turns out that NFC is this important new(ish) technology that’s enabling all kinds of local (hence “near-field”) communications. Especially, it seems, in the area of mobile payments with technologies such as Apple Pay. Anyway, my first exposure to NFC was via this business card-sized sticker that came in the VR Toolkit.
Here’s that sticker held up to the light, so you can see its integrated circuit:
As a technology NFC relies on some underlying RFID standards. Which is great because it allows me to digress and talk about how RFID was used recently at Autodesk University 2014. :-)
Here’s a picture of my AU2014 badge, held up to the same light as the above NFC chip:
Between the AU logo and my name, you’ll see another printed circuit. This was an RFID tag that allowed the event organizers to track the movement of people between the various AU sessions. People were able to opt out of this at registration, apparently, although I wasn’t aware it was possible until the topic came up during my SensorTag class (where we had a really good discussion in the room about possible uses for sensor technology). I was aware it was happening, though, and I even signed up for access to the internal dashboard.
I can tell you, for instance, that Wednesday’s exhibit hall was the best attended single event of the conference, followed closely by the opening keynote. And that 24% fewer people showed up to breakfast on Wednesday than on Tuesday. And 16% fewer on Thursday than Wednesday. Ah, big data. :-)
Anyway, let’s get back on track. The NFC tag in Google Cardboard is intended to launch an appropriate app on your (Android) device when its back comes into contact with the tag. This usually happens when you either insert the phone into the cardboard holder or you close the back flap.
These NFC tags are typically re-writable, which gives some interesting possibilities for application developers: you can very easily customize the behaviour of the DODOcase’s NFC tag, having it launch your own app or web-page when it comes in contact with someone’s phone.
The Google Play Store has a number of NFC-related apps, allowing you to read and write NFC tags. The first one I used – when I only wanted to write tags to launch web-pages – was NFC Writer by Tagstand. The tool I recommend now – assuming you want to both read and write all kinds of NFC tags – is NFC Tools.
Here’s what NFC Tools said when I used it against the standard DODOcase tag (I’ve merged a couple of screenshots to get all the data on one view):
The main items of interest are way at the bottom in Records 0 and 1. These contain the information that causes – when the tag touches the back of the phone when it isn’t in tag reading mode – Android to bring up the Google Play Store with the option to install the DODOcase app:
If the app is installed already, it’ll simply launch, of course.
So how can we get another app to load, instead of this one? Let’s take a look at how NFC Tools can be used to have a specific web-page or app launched when it touches your device.
We’ll start with a web-page for which we need a URL record placed on the tag. Here’s how to have http://autode.sk/gcbv launch when the tag touches your device:
The problem I had with this approach on my phone was that it would launch the page repeatedly, presumably when the contact between the phone and the tag was interrupted for some reason. This apparently doesn’t happen with all devices, but it was certainly enough for me to give up on NFC when I first started working on web-based samples.
On creating a native Android app, however, NFC became more interesting again, because even if a re-launch occurs, it won’t create a new instance of the app. Here’s how you can write an AAR – an Android Application Record – to your NFC tag, causing the com.autodesk.a360cardboard app (specified in the manifest shown in the previous post) to either get installed or launched when the tag is detected. (Bear in mind that this app isn’t actually in the Google Play Store so it won’t attempt to install it.)
When the tag comes into contact with your device, your custom app will launch:
That's it for this quick look at how you can customize NFC tags for use with Google Cardboard.