Google I/O 2011: How to NFC

>>Jeff Hamilton: Nick Okay. Hi, everybody Welcome to how to NFC My name is Jeff Hamilton, and I’m an engineer on the Android team working on the NFC stack >>Nick Pelly: And my name is Nick Pelly. I’m also a software engineer on the Android team, working on the NFC stack I also want to introduce you to Ben Dodson, who is an intern on the Android team and will be helping with the demos >>Jeff Hamilton: Before we get started, we’d like to point out — hold on a second. We lost the slides here >>Nick Pelly: Should we switch to the other box? >>Jeff Hamilton: Yeah Okay. Before we get started, we’d just like to point out real quick we have some links for feedback for the presentation. If you’d like to give feedback on how we’re doing up here. Also, we have some hashtags if you’re going to be tweeting about the talk, you can see up here, IO2011 and Android. We’re going to take some live questions from the audience as well as from Google Moderator. If you have questions that come up during the talk, you can put them in online, or if you’re watching the live stream, feel free to put questions in there and we’ll get to those at the end of the talk So we’re going to talk today about, you know, first, what is NFC Second, we’re going to talk about why use NFC and why this is relevant to you as developers to add to your applications Third, we’re going to talk briefly about how to NFC 101, just kind of an intro to NFC on Android and what you can do as developers to add NFC support to your applications Fourth, we’re going to talk to how to NFC 201 and deep dive a little bit more into the details of the technology So first, what is NFC? Just a quick show of hands, how many people in the audience are familiar with what NFC is? Wow >>Nick Pelly: That’s a lot >>Jeff Hamilton: That’s quite a lot of you Now we’d like to do a quick show of hands How many of the developers out there have added NFC support to their applications >>Nick Pelly: We’ve got to change this >>Jeff Hamilton: Quite a few of hands were up for the first question, not for the second We’re hoping by the end of this talk, you’ll have the information you need to add NFC support to your applications So just real quick, what is NFC? It stands for Near Field Communications. And it’s a wireless technology similar to Bluetooth or Wi-Fi where you can transmit data wirelessly Unlike Bluetooth or Wi-Fi, it has very short range. So the theoretical maximum is about ten centimeters. On a smartphone, you’re going to see closer to one to four centimeters typical range for interactions NFC is also typically low speed. So you’re going to get between your configurations, 106 to maybe 414 kilobits per second. That’s kilobits, not kilobytes. That kind of depends on your configuration as well as — these are theoretical maximum numbers. You might see lower speeds than that So those two properties, you know, don’t really compare to Bluetooth or Wi-Fi. But what’s really great about NFC is it’s a low-friction setup. So because it’s — only works at short range, anytime you bring two devices that support NFC within that range, they’re going to set up a connection and be ready to talk to each other. So there’s no discovery like you have in Bluetooth. There’s no pairing You don’t have to put in passwords or anything like that. This is really, we think, a magical property of NFC that really makes it kind of a science fiction type of technology. Things just work Additionally, NFC supports what is called passive targets. These are devices that do NFC, but they don’t have batteries in them These are things like stickers or random devices that aren’t powered, can support NFC. There’s a tiny microcontroller with an antenna, and it picks up the power from a secondary device and actually powers up the device from another one. So you can interact with things in the world and they don’t need power. And that’s a really interesting property of NFC that doesn’t exist in any other technology. And we think it really enables, you know, interesting applications for, you know, the technology and great things that people can do with it Off to Nick >>Nick Pelly: Jeff’s talked a little bit about the basic properties of NFC. And, hopefully, some of you in the audience have some ideas of how you can use these properties to build awesome applications Today, we want to make the case to you of why NFC is going to be so compelling to users Why should you care about NFC?

Well, we like to think of it as bridging the physical and the virtual worlds. Now, this is a kind of cheesy saying. But, you know, this is really true. With NFC and low proximity, you can bring two devices next to each other and it will trigger a virtual reaction. Physical actions, virtual reactions This is something that we haven’t seen from any other wireless technology. Bluetooth, Wi-Fi, you don’t have that easy connection setup. This is new to NFC, and we think users are going to love it Let us show some demonstrations So first, basic tag read. You may already be familiar with this, but we’re going to show it anyway. Everyone has a Google I/O badge. And inside it, you’ve got your NFC sticker. I’ve got one of them here right now So you may have already tried this with your Nexus S. If not, let me show you how easy it is to read content off of this tag You take your Nexus S, if I get the right phone. At the home screen, and just touch it to the tag. (chime) There you go. I’ve read Jeff’s contact details That’s the V card. So these are stickers, you can start thinking about where you might want to place these stickers. A useful one for Jeff would probably be on his front So we can now tap Jeff and read his contact details >>Jeff Hamilton: Come see me after the talk [ Laughter ] >>Nick Pelly: So these stickers don’t need any power. They’re inexpensive, they’re becoming cheaper. You can think of them a little like QR codes. You can embed basic data onto them Let’s now go to a few more demonstrations of the kind of content you can put on an NFC tag We’re going to switch to the demo board, where we have a number of tags embedded into the board so that we can quickly tap different areas and show you the NFC content in the tags These tags could just as easily be a sticker or a card or any other form factor Ben’s going to just tag a few of these and show how easy it is to read content The first one had a URL. Android.com, the Wi-Fi’s a little slow — there we are. It’s coming up. (chime) The next one has another V card. And then the next one should have some text. (chime) So, hopefully, you’re getting the idea. We can put URLs, text, contact, in fact, any MIME data type into a tag. And most importantly, when you touch the phone to the tag, it doesn’t matter where you are, it doesn’t matter that you don’t have any application running. You can be at the home screen, and it will take you to the right application to handle that content. That’s really powerful. QR codes don’t do that Let’s do a direct comparison, actually, of NFC versus QR codes This is a little bit unfair, but let’s just do it to see the difference in speed So Jeff is going to try and read a Google PLACES location embedded in a tag by scanning While Ben is going to read it from a QR code Three, two, one, go. (chime) >>Nick Pelly: And the NFC tag’s already done It’s a little bit unfair to QR. You have to fire up the application and focus the camera Good luck if you’re in low light conditions So the key point here, NFC is just really fast. It’s low friction. We think users are going to love it And you can see the sequence with QRs So let’s now go to an application that we put together in just a few days. We have APIs for NFC read, write, and peer-to-peer that are already a part of the Gingerbread platform today. So we’ve used these APIs to put together an application called Sticky Notes. It’s just a very simple application to, you know, show you how easy it is to use Ben is going to tag this phone to some text and it’s going to automatically launch the Sticky Notes application. That’s it. It’s read the content. We can now show you that it can actually write content to these tags as well. This is something we haven’t mentioned yet. These tags are reprogrammable. They are a — they have their own microprocessor. It’s not like a QR code. You can actually program these things once they’re already deployed So can we get, like, a word or a phrase that you want to put into a tag here? We can demonstrate it live Chicken. Okay >>Jeff Hamilton: Chicken it is >>Nick Pelly: That was really quick We have a lively audience Okay. Ben’s programmed it into the tag to

prove we’re not faking it. Jeff is going to use a different phone to read it back out And note it’s going to launch the Sticky Notes application again >>Jeff Hamilton: There we go >>Nick Pelly: That’s it. It’s just so easy So now the third mode — [ Applause ] >>Jeff Hamilton: There we go >>Nick Pelly: Thank you [ Applause ] >>Nick Pelly: The third that’s really interesting is peer-to-peer. Yep, you can read or write to these passive stickers, and, yeah, there are plenty of other peer-to-peer protocols, Bluetooth, Wi-Fi. What makes NFC so interesting is that it’s triggered by the proximity, so you don’t need to go fumbling around in any UI. You just put the two phones together What we have is the two phones, both in the Sticky Notes application, both with different text contents. With the Nexus S, the antennas are in the back of the phone, so you place them back to back. (chime) And they’ve exchanged content. That’s it You don’t need to go fumbling around in any menus [ Applause ] >>Nick Pelly: We’re going to show some more peer-to-peer demos, and we’re going to do it using the demo board. There’s the outline of two Nexus S phones on here. They have actually got antennas hard-wired behind them so that we can show you the front of both phones as we do peer-to-peer. But if you’re trying this at home, you’re going to want to put the phones back to back So we hope that you’re beginning to see some of the possibilities of this technology What we wanted to do was just throw together some demos of — some more sort of sci-fi, like, what can this proximity-triggered action enable We wanted to create a wormhole. We programmed two tags to be the end points of this wormhole You can imagine that one tag is in Australia; one tag is in San Francisco. And when you place one phone on the first tag, it begins the wormhole. (chime) >>Nick Pelly: And on this other tag. (chime) We’ve taken a risk with these demos. We have NFC, Bluetooth, and Wi-Fi at a conference So the Wi-Fi is a bit slow But what’s going to happen in a decent Wi-Fi connection is you’re going to have a video chat complete and you can be talking to someone on the other side of the world just through touching the phones to a tag >>Jeff Hamilton: One more time. (chime) Some people claim wormholes don’t exist >>Nick Pelly: I guess Einstein was right All right. Let’s go to another demo So we have worked with Halfbrick Studios and in just a few days, we took the Fruit Ninja application and added NFC and Bluetooth to make it head-to-head multiplayer. Head-to-head multiplayer games over Bluetooth is not really new, but what is new is using NFC to initiate the connection So we have one phone at the Fruit Ninja menu screen. The other phone can be anywhere. It’s just at the home screen right now. Put them together and see what happens. (chime) [ Applause ] >>Nick Pelly: That’s it, straight into a game Isn’t that awesome? It looks like our intern has been practicing this one >>Jeff Hamilton: He’s pretty good >>Nick Pelly: I want to be clear, everything we’ve shown you is possible with Gingerbread APIs. This can all be done today. We’re going to make it easier for developers with some additional APIs in Ice Cream. But the functionality is already there Let’s talk a little bit more about Ice Cream Sandwich I hope you’re already convinced that NFC is an interesting technology. And we really hope that we’ve got your imagination going with the kinds of activities that you can build out of this physical interaction We think it’s really interesting, too, and we think this is just the tip of the iceberg Here are some ideas that we’re going to put into the Ice Cream Sandwich release We want to really focus on these 0-click interactions We keep coming back to the one-key feature You can put two phones together without any UI, without having to launch any application, and share content So we’re going to bring 0-click sharing into the platform for Ice Cream Sandwich Let’s show some demonstrations Ben is viewing a contact. You put the other phone next to it, and immediately, it just shares that contact. This is how easy it should be [ Applause ] >>Nick Pelly: It’s sharing the on-screen contact with the other phone Let’s go to a Web page. Ben is going to load

a Web page. Android.com. Put it against another phone, and — (chime) — as you can guess, it just loads the Web page We want to build this into as many system apps as we can. And we want to make the APIs for this easily available to application developers for use with your applications So there’s one more demo that we want to show We don’t have NFC in a tablet yet, but we have hacked up this tablet with an NFC evaluation board [ Laughter ] >>Nick Pelly: To show you, you know, what can be possible when we have a broader range of devices available with NFC Let’s say you’re watching YouTube on a Nexus S. It’s got a great screen, but the tablet is so much better. Here’s what we think should happen when you touch your YouTube video to the tablet [ Applause ] >>Nick Pelly: And if you noticed, it resumes playback right where the other one left off >>Jeff Hamilton: If only I could dance that well >>Nick Pelly: So we hope we have you excited There’s one more demo that we think the application developers in the audience are going to be particularly excited about. And that is application sharing So let’s say that one phone is running Fruit Ninja. The other phone doesn’t have Fruit Ninja installed. What should happen when you put those two phones together? Well, let’s demonstrate >>Jeff Hamilton: Let’s see (chime) >>Nick Pelly: There you go. Take you to the market to download it. This is going to encourage viral app sharing. If you and your friends you want to share an app to a friend, you don’t have to go search to it in the market You can just touch your phone to theirs and they can download it I will now pass back to Jeff for how to NFC >>Jeff Hamilton: Thanks, Nick. Those were some great demos So we have seen a little bit about what you can do with NFC, what the technology is like And hopefully you all are starting to think about what kinds of things you can do in your applications using NFC Let’s talk a bit about how you would do that First we’re going to talk quickly about how to read data over NFC. Then we’re going to talk how to write data over NFC. And then we’re going to get into some more advanced topics at the end The first thing to know when reading data from NFC is that there’s a data structure called NDEF, this stands for NFC Data Exchange Format. It is the data container format to use for NFC The reason that there needs to be a standardized data container format here is that on the passive tags, there’s a lot of different types of technology that exist, and they all have a lot of different properties, different ways they store data on them, and things like that So the standard NDEF here is designed to be able to work across all of these different types of technologies. And it’s just a way you can interact with NFC devices and be guaranteed that you’re going to have a common data structure across these devices for many different vendors The general structure of NDEF is, first you have a message, and the message encapsulates within it one or more NDEF records And the message is just an encapsulation of records. The records that you have in there, each record has a high level type, and then there’s optionally a second level type that’s scoped within the first level type. There’s an optional ID within the record. And then there’s an optional payload as well For more information about NDEF messages and NDEF records, the NDEF message and NDEF record classes in the SDK, there’s a bunch of documentation there with the gory details >>Nick Pelly: NDEF was the contain format we used for each of those demos >>Jeff Hamilton: The first thing to know about NDEF when reading it on the phone is how it’s going to be dispatched to your application So by design, the NFC data is dispatched to only one activity on the phone. And we think this is actually a very important aspect of the way we design the system. Because when users are interacting with things with NFC, they really are looking for instant gratification for the way that they’re interacting with things around them in space. And so what we really wanted to do is launch directly into the application that handles the data that they’re interacting with. And we really think that, you know, for the best experience for the user, going directly to the application is very important so that they can interact with things around them So let’s talk a bit about how you get into your activity when data is read over NDEF So what we do is we take the first NDEF record in the NDEF message and we look at its type And we build an intent from that type

So this slide shows some examples of how we are going to take an NDEF and convert it into an intent. And we show that on the right-hand side with some snippets from an Android manifest file, and this is how you would capture NDEF data coming into the phone from your activity So the first two examples show how we handle just raw text coming in. So the Sticky Notes example we showed earlier handles text plain line type, and it just deals with general text So there are two ways you can get general text. There is a top-level type well-known with a secondary type of text, and the payload is just text The second one is you can have MIME data in an NF record, so if you have MIME data and the secondary type is text plain, the payload again would be just text. And what we do is we take the MIME type there, text plain, and we put that on the MIME type field for the intent that we start when the data comes in, and that let’s applications filter on the different types of data they are interested in So taking that a step further, the third example here is using the application slash VND.example and this is the generally accepted format of doing vendor specific MIME codes or MIME types So this is something we think would be great for developers. If you have a data structure you want to put in a sticker or you want to transfer over peer to peer, you can just create your own custom MIME type using VND dot and then your domain name and put your payload in there What we do is we take that MIME type, put it into the intent and from your Android manifest you can specify you want that MIME type coming in from NDEF, and then your application will get launched directly to handle your data structures And the last example, we can do basically the same thing using a URI. So there are three different ways you can store URIs in NDEF If we find one of those three ways, we pull the URI out, and we set that as the data field on the intent, and you can use the existing standard Android manifest matching mechanism for saying which URIs you are interested in And you can be as specific or generic as you want when setting up that match in the system >>Nick Pelly: You can think of NDEF types as like a superset of MIME and URL types, and Android does the work for you in mapping those to MIME or URL types for intent filters >>Jeff Hamilton: Okay. So now we talked a little bit about how we build that intent, let’s look at some code snippets for how applications would actually handle that The first one we have here is the Android manifest from the Sticky Notes example we showed earlier, and it’s just an extra intent filter that has the action NDEF discovered on there. And this one, for the Sticky Notes, was looking for text, so it set the MIME type to text plain Here you would just put in, in this intent filter, you would put in some kind of filter there for whatever data type you have that your application is dealing with over NFC The second code snippet we have here is just the activity and how it would handle it when it receives that intent. There’s basically just an extra on the intent, it’s called extra NDEF messages and that’s an array of NDEF messages. Typically there’s only one NDEF message that comes over the payload, but it is an array because it is possible in some cases to have multiple NDEF messages. So typically you just look at the first NDEF in that array, get that NDEF record in there and off you go >>Nick Pelly: This code snippet is straight from the Sticky Notes application that we demonstrated, and the full code is available, is linked at the end of the presentation >>Jeff Hamilton: Let’s talk a bit about best practices when dealing with NFC and NDEF data I think this is very important that you always want to use precise intent filters. You don’t just want to say I capture URIs that all have HTTP as their scheme because if multiple applications are doing that, you are going to get something like we have in the slides here where you have an activity chooser dialogue, and the user is really not going to have that instant gratification that we think is the hallmark of NFC and what makes the technology really exciting for users, and it’s not going to be a great experience for them So we highly suggest that you structure your data in ways that you can create precise intent filters with custom MIME types or with URIs to domains that you control so you are not going to be stepping on each other toes, and it will be the best experience for all the users out there Another thing worth mentioning as well we talked earlier about how NFC is kind of slow on the data transfer rate, so we also recommend that you keep your data structures on the smaller side. Typically, one kilobyte or less is a good recommendation >>Nick Pelly: Please, no XML over NFC >>Jeff Hamilton: Okay. So we talked about reading NDEF. Now let’s talk about where you can read it from So you can read it from passive tags, as we showed in the demos earlier. There are a bunch of different types of passive tags. So the

NFC forum has gone out there and they specified four standardized types of passive tags. They are called type 1 through 4 We have up here some examples of products that implement these specifications. These are the most common implementations of these specifications that you find out there, although they are not the only implementations that exist. There is the Topaz, type 1; MIFARE Ultralight, type 2; Sony Felica, type 3; and MIFARE Desfire, type 4 Outside of the NFC forum defined types, there are also some proprietary NFC tags Micro classic is the best example of that. There is tons of micro classics out there in the world today, and they support NDEF as well Because they are completely standardized, support for those is optional in Android Not all devices are necessarily going to be able to read these tags. The Nexus S can read them, but if you are putting a deployment out there in the world, we highly suggest you go with one of the standard type 1 through 4 tags because then you will be guaranteed that all devices will be able to read them and you won’t run into any problems with people who have devices that can’t read the type of tag you have deployed And last but not least, you can read NDEF peer to peer. And this is from one Android phone to another. And we think that’s a very exciting way to read it as well So we talked earlier about NFC stickers. I think you have all probably seen these in your badge sheaths. The stickers we have given you are type 4 tags that can hold up to two kilobytes of data in them. If you read the sticker in there with the Nexus S, it will take you to a Web page that has a link to documentation about NFC, some sample code from Sticky Notes application, as well as a link to the NXP tag writer application from our friends at NXP, and you can download that from the marketplace and you can use it to rewrite the tag and play with it and put whatever data you want in there One thing to note, these tags are rewritable so you can put whatever data structures you want in. There you can play around with them, use them to develop applications. But beware that you can’t make them read only. So if you are going to put them up, stick them around somewhere, be aware that someone might come around and rewrite them on you and who knows what they will put in there Keep Nick away from your tags Okay. So let’s talk a bit about writing in more detail As we said, NDEF tags can be writable. It’s also possible to configure the tags to be read only from the factor tree when you purchase them. The type 1 and 2 tags it’s possible to make read only at any time. If you had a read/writable tag, you can mark it read only and that will be honored in the tag For types 3 and 4 they have to be configured as read only from the factory. So if you get a read/writable tag like the ones we’ve given you guys today, you can’t mark that tag read only later on. So that’s something to be aware of if you are looking to deploy tags out in the field So when you go to write tags programmatically on Android, you have to do that when the tag is in the field of the phone. So that’s when the tag is touching the phone, pretty much And we have a code snippet here, again from our Sticky Notes sample code. You can go down to the sample code on the Web page. Basically you just create an NDEF record that has the text that you want to write into it, encapsulate that in a NDEF message, and then get a reference to the tag object that you want to write to and the NDEF technology you are going to use to write, and then just call write NDEF message and it goes out over to the tag and you are good to go So writing peer to peer is a little different The way we set it up on Android is only the foreground activity can register a payload to push over a peer-to-peer link So the application needs to register that payload in advance. It’s something that we think is really important in the way the APIs are set up, because we want to make sure the user is aware of which activity is using the NFC radio >>Nick Pelly: I think it’s a common theme about APIs, actually. We always want to encourage the foreground activity to be the one using NFC. It’s for instant gratification so the user knows exactly which application is using the NFC link >>Jeff Hamilton: So your application on resume we just call the NFC adapter, or API enable foreground NDEF push. And you head off an NDEF message. So what happens then is the system will take that NDEF message, and when a peer-to-peer link is established, it will hand that NDEF message over to the other phone on the end of the peer-to-peer link, and it will dispatch that NDEF message as if it had been read from a passive tag >>Nick Pelly: You can use the same code on the receiving side for peer to peer as you used for reading a passive tag. It looks the same. You just receive a NDEF payload >>Jeff Hamilton: So this is a really nice

API, we think. It makes it very easy to add peer-to-peer support for NFC on your applications You just need to call enable foreground NDEF push from your on resume and hand off the content One thing we thought would be handy on the API, and unfortunately we didn’t get it into Gingerbread, we will add this in Ice Cream Sandwich, is you can add a callback system — you can register a callback. So when the peer-to-peer link is brought up, there will be a call back made to your application and you can return a NDEF message at that time that’s relevant to the state of your application when the link is established So that’s something you saw earlier with the YouTube example. The YouTube application on the phone is using this Ice Cream Sandwich API, and it’s responding with not only a link to the video that its playing back but also the time stamp of where it is in that video so the other side can start playback at the same point >>Nick Pelly: Okay. So Jeff’s covered the basics of how to NFC. And we really focused on NDEF tag read, NDEF tag write, and NDEF peer to peer. There’s a theme here. We’re talking about NDEF. But are all NFC tags NDEF? Well, they are not. So we are going to go into detail about the NFC ecosystem on a broader level. Don’t worry, we are not going to go too deep. There’s a lot to talk about here but we will just make you aware of some of the things that you should know So NFC as a technology has actually been around for over 15 years. But NDEF is a fairly new standardization. And over that 15 years, companies have invested heavily into NFC for transit, for credit cards, for passports, for physical access cards. There’s over 5 billion of these already out there that your Nexus S or other Android NFC phone can talk to already Now is probably a good time to bring up RFID We haven’t mentioned it yet. RFID is a different technology to NFC and it really bugs me because I keep reading articles where they replace NFC with RFID. They are different set of technologies RFID is typically working at a range of meters NFC is exclusively a centimeter range technology This is really important. This means that you were going to get that proximity triggered interaction, physical reactions, virtual reactions And it means that you don’t have to worry so much about many devices being in the field or privacy and security Anyway, so when we quote the 5 billion number, that’s 5 billion NFC tags So this is our crazy diagram of like all the different NFC technologies that — actually, it’s a subset of the technologies that have been out there for the last 15 years. When we rehearsed this, I can talk for half an hour about all these technologies, but my product manager was like, no, let’s just spend 30 seconds So all I want to do is let you guys know there are a bunch of different technologies that are all sort of — fall under the NFC ecosystem And all those tags that are deployed that are non-NDEF are going to use one of these technologies Now, the good news for you guys today is we have built APIs to the majority of these technologies so that you can read and write with all of these legacy tags that are already out there today [ Applause ] >>Nick Pelly: So I won’t go into the detail, but if you want to look into using these classes, the package is android.NFC.technology. We have a set of classes like IsoDep, NfcA, NfcB, NfcF. If you know NFC well, you might have heard of some of these before. And we have all the low-level commands you need. You know, transceive, authenticate, read, write, to use all of these technologies from your Android applications So I will mention that when I say technologies, I kind of mean protocol. Any given tag can have an RF level protocol and then one or more other protocols building on top. So don’t be surprised when you see multiple technologies enumerate on a single tag Now, we talked about dispatching to application with NDEF. We use the NDEF discovered intent It’s a start activity intent so we always are bringing an application to the foreground It’s the same with non-NDEF tags. We use the tech discovered intent, it’s a start activity intent. We are trying to bring the application to the foreground so the user gets instant gratification The content you filter on is no longer the NDEF type because we don’t know the type It’s some unknown tag with different technologies on it. So instead you filter on the technologies

you want to use So, for example, if you are writing an application to read information off of a transit card, you might specify that you are looking for cards with NfcA and IsoDep because you know all the transit cards you care about have those technologies >>Jeff Hamilton: I think it’s worth noting it happens before the technology phase So if you’re writing an application and you’re using NDEF and you’re using the intent filters like we described earlier for NDEF data, that’s going to happen before the technology discovered happens So, basically, we call start activity if we get any results back for activities that handle that NDEF data structure. We just launch directly into them. If there are no activities installed in the system that handle that NDEF data structure, then we’ll go on and try to dispatch and call start activity on action tech discovered with the technologies that are present on the tag that’s in the field So if you’re using NDEF, that takes precedent over the technology level. We think that’s kind of important, because NDEF allows much more precise filtering to applications, and, you know, that’s a great way to get directly into your application for a better user experience >>Nick Pelly: Please use NDEF if you can But if you can’t because you’re using legacy tags, then look at tech discovered While we’re talking about dispatching tags to your applications, there’s one other important dispatch mechanism we want to mention We have an API function, enable foreground dispatch When your activity is already in the foreground, you can call this to tell the Android operating system that you want to receive all further tags into your application and not some other application. You know, this is really important, because otherwise, if you’re trying to write to a tag from your application and then you scan a tag, you can make sure that you’re not going to launch to some other third-party application. It’s going to stay in your application and you can receive all the new tag updates So this is a good tip to look at enable foreground dispatch Okay, I just talked a whole bunch about passive tags, reading and writing. Let’s talk a little bit deeper about peer-to-peer The key feature of NFC for peer-to-peer is that it’s low friction. There’s no discovery, there’s no pairing. You just touch the phones together and it will launch the application However, it’s got a low range. It’s only going to work when they’re sort of one to four centimeters away. That’s not great for playing a multiplayer game. And the data rate is really slow So like with the Fruit Ninja demo, we really recommend to switch to a high-bandwidth connection like Bluetooth, or you can equally well use Wi-Fi, or even go through the cloud for your heavy lifting in the application Bluetooth and NFC, they go together so well We really recommend you look at this >>Jeff Hamilton: Wireless nirvana >>Nick Pelly: NFC to initiate the connection, and then Bluetooth for the — the heavy lifting Please don’t do socket-style communication with NFC. It doesn’t work so well Okay. We’re getting towards the end. We just want to recap on the key points that we’ve presented to you today Number one, I think we’ve said it a few times now, but just to hammer it home, NFC is quick connection setup is what it’s about. So please think about how you can use this in your applications and the kinds of experiences your users are going to get out of this Number two, you can work with passive devices, stickers, tags. You can take these stickers and just, you know, place them around the environment, on people, and just, you know, see what happens NDEF dispatch, use precise intent filters and prefer NDEF over the legacy technologies Number four is, foreground interaction. The APIs are designed to work in the foreground So, you know, we really don’t want to encourage applications to be using the NFC connection in the background And lastly, for socket-style communication, please use Bluetooth or some other, you know, higher-range connection We’re about to go to Q&A, but I want to just cover a few topics we know are going to come up first Privacy. So, you know, when we work with NFC, we often hear people talking about privacy And, you know, it’s a really important topic to discover. Because we do care about user privacy. I don’t want people reading my contact information out of my phone without me letting them. So I want to touch on a few points First of all, NFC is not RFID. It does not work at a range of meters. This is a centimeter technology. You have to be really close to the phone in order to communicate with the NFC antenna. It’s a very low-powered antenna

Second point is, yeah, NFC is off when the screen is off. So, you know, as I like to call it, there’s no butt-sniffing. You can’t go and scan someone while their phone’s in their back pocket and the screen’s off [ Laughter ] >>Jeff Hamilton: That’s a good thing. You don’t want Nick doing that to you >>Nick Pelly: I thought you took that out of the slides And lastly, third-party applications, they must be in the foreground. We really think this is the right usage model. It’s instant gratification. And it means that you know which applications are using the NFC link and you know if they’re misbehaving Okay. Second hot topic is security. It’s related to privacy, and some of the important points are similar NFC is, by design, low range and low power So if someone was to try and intercept or eavesdrop on a communication, they’re going to be need to be very close in order to see what’s going on Now, that said, there is no link-level encryption built into the standard NFC protocols. So if you care deeply about the payload, if the payload is a financial instrument or something else that you need to keep secure, then you should encrypt it or you should look at some of the more advanced NFC technologies that do have encryption built into the lower level But by default, don’t assume that the link level is encrypted Lastly, card emulation. This is the most popular question on Android developers’ Google Groups So we talked a lot about reader/writer mode and peer-to-peer. There’s a third major mode of NFC, which is card emulation. This is when the Nexus S is pretending to be a passive tag that you can put in the field of a reader/writer So if you wanted to pretend to be a transit card or pretend to be a credit card. So in Gingerbread, we have no API support for card emulation. And it’s not that we forgot. We thought very hard about it. But there’s some simple reasons I showed you that diagram earlier of all those different technologies. Well, if you’re going to do card emulation, the hardware has to pick one of those technologies to emulate You can’t typically emulate all of them at the same time. And the hardware out there today doesn’t actually support all of these at the same time anyway So if we were to build these APIs, the applications are going to have a really inconsistent experience as they’re deployed to different Android devices Some will support NFC A, some will support NFC B. We don’t think this is really going to be a great story for third-party developers right now And secondly, when you’re doing card emulation, you’re emulating a passive target that is going to have one kilobyte, two kilobytes of memory. You’re going to then have to decide which application has the right to manage this limited resource So we did not put card emulation APIs in Gingerbread because we want to make sure that we have a compelling user story before we do that And we really think that peer-to-peer is the way to go for future NFC uses. Peer-to-peer and NDEF, because with NDEF you can filter on content. And with peer-to-peer, it’s a newer technology. It doesn’t have to assume that one side is passive So that’s it for the main part of the presentation We encourage you to go to NFC.android.com We have links to the sample code for Sticky Notes, links to the developer APIs. And you can give us feedback on how we went today at the feedback link. You can tweet about this with the hashtags. And we’re going to now take questions from the audience live, and also, you can post questions online at the last link Thank you [ Applause ] >>Nick Pelly: Okay, can we get the first question live, in the brown shirt >>> So what can you tell us about your plans for other devices that support — that will support NFC in the near future, other than the Nexus S? >>Nick Pelly: Well, I think, you know, it’s up to the OEMs. You know, I think they are going to want to — they would love to see more applications in the market. So it’s kind of up to you guys to write some really great applications out there that really, you know, make the OEMs see the use cases for NFC. Yeah, and, you know, we do know personally of dozens of phones in the pipeline for 2011 that are

going to have NFC. So don’t worry, they will come as well >>> Thank you >>Jeff Hamilton: Take a question from the back mike, please >>> So are there intents, then, to update all of the standard apps, contacts, GMail, the browser, to have a standard NDEF payload that they’re just showing all the time? >>Jeff Hamilton: Yes. So that’s something that we showed off in the Ice Cream Sandwich preview. That’s something we’re going to look at adding in the Ice Cream Sandwich platform You know, in the demos that we showed, like, from contacts, it’s exporting a standard V card. So it’s a MIME type, which is V card So that’s a pretty big standard there. URIs come through just as a URI. There’s an NDEF specification for how to store URIs, so those come through just like that. So NDEF as a format covers pretty much all the data structures that we’d export. And for things like contacts, we just go with the standards like V card >>> All right. So Ice Cream Sandwich is when we’d start to see that just show up in the standard apps? >>Jeff Hamilton: Yeah, in the platforms So in your applications today, you as developers can add support for this stuff today on Gingerbread >>Nick Pelly: We’ll take a question from the Google Moderator Are we going to have a way of using NFC in the emulator? And that’s something that we get asked a lot And I think, you know, for right now, we really encourage you to buy a Nexus S and use it with real hardware. But we are working on it for the emulator. And hopefully soon >>Jeff Hamilton: Yeah, I think that the problem with the emulator is they’re — as we saw with that diagram, there are so many different technologies that exist in the realm of NFC And it’s very difficult to support all of those simultaneously in the emulator. So that’s something we’re working on >>Nick Pelly: Question from the front >>> So the lack of card emulation support, does that mean you can’t do mobile payments with NFC as it’s implemented in Gingerbread? >>Nick Pelly: It means that you can’t do mobile — you can’t do mobile payments with the APIs available in Gingerbread >>> And are you planning to add that in for Ice Cream Sandwich? >>Nick Pelly: It’s something that we’re not going to rule out >>> What’s the sort of missing pieces there that you’re looking for to make that what you call a compelling environment to enable that? >>Jeff Hamilton: At an API level, you mean? >>> I think, if I understood, you were saying it’s just not a compelling proposition right now. What are the missing pieces to make it compelling? >>Nick Pelly: The problem is that the hardware out there today, you know, if you buy an NFC controller, it typically is only going to be able to emulate one of those RF-level technologies So as an application developer, you don’t know which — when it’s getting deployed to a phone, which one is on the phone. So I guess until we see the industry standardize around maybe one RF-level technology or until we see NFC controllers able to support multiple of those. I guess we’re actually hoping that everyone will just move to peer-to-peer or NDEF exchange, because that removes this problem entirely >>> Looking for a standard in the frequency supported? >>Nick Pelly: In the modulation of the — they all do 13.56 megahertz, but they have different modulation schemes >>Jeff Hamilton: Take a question from the back mike >>> Okay. I understand this is peer-to-peer and very close communication. But for the passive tag reading-wise, I don’t think there is any restriction for, like, reading two devices at the same time for the passive tag Is it true or is it not? >>Jeff Hamilton: Currently, the Nexus S only supports reading one passive tag in the field at a time There are a few technical limitations in place And more than that, you know, we think there’s really just a user interaction limitation there where, you know, as we talked about, we thought — we think it’s very important for the users to go directly to the application handling the tag they’re interacting with for that instant gratification. So if the stack is handling two tags at once, if they both have NDEF payload, it’s not clear what activity is going to be launched >>> Right, right >>Jeff Hamilton: So we really think that the best part of NFC is that it’s just kind of — it instantly happens for the user. And so for that reason, right now, you know, we only support one — >>> Who is handling those sequences, basically >>Jeff Hamilton: Who is handling that sequence? >>> Yeah. If you have a passive tag and then both reaches at the same time, who is — >>Jeff Hamilton: So if you have two passive tags in the field, it’s going to arbitrarily pick, you know, one to be the first tag. And I think that depends on the ID of the tag And the way it works is a polling loop. So the radio in the phone will look to see what exists in the field. And I think that kind of depends on which tag ends up responding first in the field. It’s pretty arbitrary >>> Okay. Thanks >>Jeff Hamilton: Yep >>Nick Pelly: Maybe a question from Google Moderator Is Google going to partner with somebody to bring real-world NFC use? E.g. mobile payments For mobile payments, nothing to announce

I think — you know, we’re looking at peer-to-peer, and we’re looking at bringing 0-click sharing to Ice Cream Sandwich. And these are what we see as the use cases today >>Jeff Hamilton: Okay. Question from the first mike >>> Is there a type of NFC tag that allows an administrator only to write to it? >>Jeff Hamilton: Yes. There are different levels of encryption, authentication support in the tags that we talked about Some of the tags support doing authentication using a shared key. And they have different access control rights in them. So the tags that you have actually do support that. And they’re using the default keys. So what you can do is you can authenticate with the tag, using a — you know, a shared key, and, you know, that might give you, based on the access control, rights to modify the tag, where, you know, if you don’t have that administrator key, you would only have rights to read from the tag >>> And that’s type one that does that? >>Jeff Hamilton: Type four, I know, does that It depends on the product specifically. So the MIFARE Desfire definitely supports that Type one and two I don’t believe do that Type one and two are simpler tags. They have smaller data storage. They’re also a lot cheaper as well But type four, if you get the MIFARE Desfire, will do that that. Off the top of my head, I’m not quite familiar with the exact capabilities of other products >>> Thank you >>> Hi. In your examples, you had one phone ring an application and the other phone was on the home screen, so it was pretty obvious when you did peer-to-peer which way that data transmission was going to happen. What happens if there’s an app running on both, when both are active and want to share data? >>Nick Pelly: We’re still debating what to do there, actually. It’s a really good question >>Jeff Hamilton: So right now, if you have foreground dispatch enabled in your application, everything will come to you. So our advice would be, you know, if you really care about this in your application, you can — you know, you can set up your NDEF push. You can also enable foreground dispatch. That means while you’re in the foreground, trying to do other things over NFC, you’ll get messages coming, all the messages inbound, even if they’re not destined for your application. And you can either drop them on the floor if you want, or you can indicate to the user that, hey, I got something from the other side that’s not mine. You might want to do something about that >>> So if there’s two separate apps or if there’s the same app running on both phones, can they exchange information both ways during that one connection? >>Jeff Hamilton: Yeah, the data will go both directions. And it will get dispatched on the other side, depending on the dispatch stuff we talked about earlier If you’re going to go with the NDEF push, we suggest also going with the foreground dispatch, and then you have control over the inbound stuff while you’re expecting to do NFC transactions with another phone >>Nick Pelly: Okay. To Google Moderator Can I add an adapter to my cell phone to support NFC? And the answer is, yes. We just showed it But we had to hack up the kernel, so — >>Jeff Hamilton: Yeah, it was a bit of a hack So there aren’t any existing adapters today Maybe someone will build one with the Android hardware developer kit announced earlier today, hopefully What you can do is you can get stickers that are designed to be put on the backs of phones And there are special stickers that have, like, a ferrite shielding on them because the stickers have antennas in them and they’re pretty sensitive to the other radios in the phone. So if you’re interested in doing interactions with phones, you can put a sticker on the back. And, obviously, you can’t update the content of the sticker from non-NFC phones, but you could do something like put in Bluetooth addresses of the phone on that sticker on the back of it Question from the first mike >>> How durable are the tags themselves? Would they be wearable and washable? >>Nick Pelly: I think you should keep that tag on for a few days and see >>> If I wanted to put the tag on my back pocket and be slapped by a phone, would that be possible >>Jeff Hamilton: It depends. Basically, the tags are a little IC on here as well with an antenna. And then that’s all kind of packaged together. There are lots of different people doing different types of packaging. So right now, you know, you can get stickers. You can get, you know, stickers like I talked about with the ferrite shielding on them specifically for cell phones. There are people doing things that you can put on CD cases to do renting movies, that kind of stuff >>Nick Pelly: I think some people are working on washable NFC tags that you can embed into clothing similar to inventory tracking tags I think we’ll see those coming soon Question from the back >>> Suppose a user is writing to one of the tags that you provided and the payload is nearing the limit, the two kilobytes or whatever Given the amount of bandwidth available, it can take several seconds to do that right Is there anything in the API to ensure the integrity of that data or do you have to kind of roll that yourself, or — >>Jeff Hamilton: What you can do is — the code snippet we had was pretty simple. When you get the reference to the tag in the field, you can query it to see what its capacity is. So what you can do is check to see, you

know, is your data payload larger than the capacity of the tag. And you can check that up-front Beyond that, you know, when you get — basically, if the tag, say it leaves the field while you’re in the middle of doing that operation, you would get, like, an I/O exception thrown to your application What exactly the state of the tag is at that point, I’m not sure, probably depends on the specific tag technology that you’re writing to >>> Gotcha >>Nick Pelly: Okay. Question from Google Moderator Will developers be getting access to the secure element? >>Jeff Hamilton: So this one kind of goes almost hand in hand with card emulation Typically, the hardware is set up to do card emulation through the secure element Right now, we don’t have any APIs to talk to the secure element. And we think that we probably won’t be getting APIs to do that anytime in the near future in the SDK There are a bunch of different reasons. Again, the secure element is a very limited resource It can’t hold a large amount of data in there And if we open it up to any third-party application, there’s going to be a huge resource contention over the secure element Additionally, to talk to the secure elements, even from applications on the phone, you need to authenticate yourself properly And if you improperly authenticate yourself a certain number of times, there are secure elements out there that will physically destroy themselves and can never be recovered. So that’s something that we really think would be a bad experience for users, and we don’t want developers getting blamed for, you know, breaking hardware. It would be tough to know which application did it. We think it would be a very bad situation. So today, you know, we don’t have APIs for that. And there are some constraints that make it tough to create APIs in the SDK for any third-party application to talk to the secure element >>Nick Pelly: Question from the front >>> I know you said that card emulation isn’t going to be supported anytime soon and that it’s because of all the legacy reasons. But are there any vendors out there today that are building payment solutions that are based on peer-to-peer or, you know, NDEF so that we can actually, you know, take our phones to local Starbucks and pay for coffee, you know, using Nexus S? >>Nick Pelly: I really hope so. I’d love to see peer-to-peer used for payment technology — used for payment I think NDEF and peer-to-peer are the way to go going forward >>> But are you aware of anything that’s already in the works? >>Nick Pelly: No >>> And second question, and this may be irrelevant, but I know it’s only on while the screen is on. But what are the power or battery effects of having the NFC enabled? >>Nick Pelly: It’s about five milliamps in polling mode. So it’s pretty negligible compared to the back light >>> Okay >>Jeff Hamilton: Question from the back mike >>> I am just curious. What’s the smallest footprint size of the NFC stickers or tags that you’ve seen? Is it pretty much like that technology requires it to be that big? >>Jeff Hamilton: The smallest I’ve seen is 30 millimeter round, which is actually pretty small if you look at it. I think the bigger the antenna is, you know, the better — the longer range you’re going to be able to interact with it >>> I see >>Jeff Hamilton: But I have seen 30 millimeter round, which is actually pretty small >>Nick Pelly: It’s 13.56 megahertz is used for all NFC technology. So you have some fundamental constraints on the antenna size, especially when you’re powering a passive target >>> Thank you >>Nick Pelly: Going to Google Moderator, does the Google NFC team see value in the intersection of NFC and identity? If so, what in the present set of APIs is useful for NFC-based identity? I mean, I think we see value for NFC all over the place. And, you know, not — not only specifically an identity, but for so many different use cases. And, you know, we’re not going to be able to explore all of those We’re trying to put together the APIs for developers to try and build apps themselves And I guess specifically the APIs available presently while there’s the low-level APIs for, you know, transceiving to any tag. So there are some tags that have secure storage on the tag. You can use low-level APIs to actually interact with those. Or, you know — all the APIs we presented to you today are around NDEF >>Jeff Hamilton: Question from the front >>> Actually, the four record type definitions in standards, but you didn’t mention about the generic controls. So when are you going to support that? >>Jeff Hamilton: We don’t have support for it today. We don’t actually have plans for supporting that right now in the dispatching mechanism. So if you’re building an application, you can get the technology level and you can look at that, and you could interact with the — you know, the — at the technology level and get the NDEF off the tag >>> So could a vendor define their own, you know, generic, you know — the control for their own sake? >>Jeff Hamilton: So for — you can define

that. It just wouldn’t get dispatched using the NDEF-discovered intent And part of the reason there is that the specification there doesn’t fit very well into the Android intent system. So it’s not a great way to map that into intents and allow applications to filter properly >>> Okay >>Nick Pelly: So I think we’ll just take one more question, then we’re out of time. But we’re available in the office hours afterwards, and hopefully tomorrow So one more from the back >>> Okay. I just wanted to ask about the critical mass issues So, basically, you’re talking about hardware here. This is not like a QR code where anyone can print one out in a home machine. A, can I just go down to a store and buy a roll of NFC stickers B, there’s going to be a period of time in which people get frustrated when they try to hold two phones together and nothing happens, because the NFC support is not implemented yet in 100% of the apps So how do you get from here to critical mass? Will there be a symbol on the screen of apps, like a standard symbol that says, “I support NFC”? How do you get to critical mass and overcome the hardware issues especially? Because these things, you can’t just make them out of thin air >>Jeff Hamilton: The first question, if you look on the Internet, you can’t just go to a Best Buy or a Fry’s or something and just pick up a roll of stickers today. There are vendors on the Internet that will sell them to you. They’re not super easy to come by today. We’re hoping that will change as NFC gets deployed in more phones and more consumers are starting to interact with the technology Additionally, you know, for the second question, you know, I think — you know, we’ve added it to the Nexus S, and we’re really hoping that people find value in the technology and developers started adding support for it to their applications and then more OEMs will add NFC support to their hardware In terms of identifying which applications have NFC support in there, we’ve been toying around with some ways to try to expose that information to the user. But we don’t really have anything specific to announce today >>Nick Pelly: I think it’s the chicken and the egg problem. And I guess we’re the chicken >>Jeff Hamilton: Yeah. All right Well, we’re out of time now. So thank you, everyone, for coming. We appreciate it [ Applause ] >>Jeff Hamilton: And we’ll be in office hours if you have more questions >>Nick Pelly: Thanks a lot