diff --git a/docs/html/guide/topics/nfc/index.jd b/docs/html/guide/topics/nfc/index.jd index c4917b4db5dde..f907b7057dc82 100644 --- a/docs/html/guide/topics/nfc/index.jd +++ b/docs/html/guide/topics/nfc/index.jd @@ -14,17 +14,17 @@ page.title=Near Field Communication The Tag Dispatch System
Near Field Communication (NFC) is a set of short-range wireless technologies, typically - requiring a distance of 4cm or less. NFC operates at 13.56mhz, and at rates ranging - from 106 kbit/s to 848 kbit/s. NFC communication always involves an initiator and a target. - The initiator actively generates an RF field that can power a passive target. This - enables NFC targets to take very simple form factors such as tags, stickers or cards that do - not require power. NFC peer-to-peer communication is also possible, where both devices - are powered. -
- Compared to other wireless technologies such as Bluetooth or WiFi, NFC provides much lower - bandwidth and range, but enables low-cost, un-powered targets - and does not require discovery or pairing. Interactions can be initiated with just a tap. -
- An Android device with NFC hardware will typically act as an initiator when the screen is - on. This mode is also known as NFC reader/writer. It will actively look for NFC tags and start - activities to handle them. Android 2.3.3 also has some limited P2P support. -
- Tags can range in complexity, simple tags just offer read/write semantics, sometimes - with one-time-programmable areas to make the card read-only. More complex tags offer - math operations, and have cryptographic hardware to authenticate access to a sector. - The most sophisticated tags contain operating environments, allowing - complex interactions with code executing on the tag. + requiring a distance of 4cm or less. NFC operates at 13.56mhz, and at rates ranging from 106 + kbit/s to 848 kbit/s. NFC communication always involves an initiator and a target. The initiator + actively generates an RF field that can power a passive target. This enables NFC targets to take + very simple form factors such as tags, stickers or cards that do not require power. NFC + peer-to-peer communication is also possible, where both devices are powered.
+ +Compared to other wireless technologies such as Bluetooth or WiFi, NFC provides much lower + bandwidth and range, but enables low-cost, un-powered targets and does not require discovery or + pairing. Interactions can be initiated with just a tap.
+ +An Android device with NFC hardware will typically act as an initiator when the screen is on. + This mode is also known as NFC reader/writer. It will actively look for NFC tags and start + activities to handle them. Android 2.3.3 also has some limited P2P support.
+ +Tags can range in complexity, simple tags just offer read/write semantics, sometimes with + one-time-programmable areas to make the card read-only. More complex tags offer math operations, + and have cryptographic hardware to authenticate access to a sector. The most sophisticated tags + contain operating environments, allowing complex interactions with code executing on the tag.
The {@link android.nfc} package contains the high-level classes to interact - with the local device's NFC adapter, to represent discovered tags, and to use - the NDEF data format. +
The {@link android.nfc} package contains the high-level classes to interact with the local + device's NFC adapter, to represent discovered tags, and to use the NDEF data format.
| {@link android.nfc.NfcManager} | - -A high level manager class that enumerates the NFC adapters on this Android device. - Since most Android devices only have one NFC adapter, you can just use the static helper - {@link android.nfc.NfcAdapter#getDefaultAdapter(Context)} for most situations. | +A high level manager class that enumerates the NFC adapters on this Android device. Since + most Android devices only have one NFC adapter, you can just use the static helper {@link + android.nfc.NfcAdapter#getDefaultAdapter(Context)} for most situations. |
| {@link android.nfc.NfcAdapter} | -Represents the local NFC adapter. Defines the intent's used to request - tag dispatch to your activity, and provides methods to register for foreground - tag dispatch and foreground NDEF push. Foreground NDEF push is the only - peer-to-peer support that is currently provided in Android. | +Represents the local NFC adapter. Defines the intent's used to request tag dispatch to + your activity, and provides methods to register for foreground tag dispatch and foreground + NDEF push. Foreground NDEF push is the only peer-to-peer support that is currently provided + in Android. |
| {@link android.nfc.NdefMessage} and {@link android.nfc.NdefRecord} | -NDEF is an NFC Forum defined data structure, designed to efficiently - store data on NFC tags, such as text, URL's, and other MIME types. A - {@link android.nfc.NdefMessage} acts as a + | NDEF is an NFC Forum defined data structure, designed to efficiently store data on NFC + tags, such as text, URL's, and other MIME types. A {@link android.nfc.NdefMessage} acts as a container for the data that you want to transmit or read. One {@link android.nfc.NdefMessage} - object contains zero or more {@link android.nfc.NdefRecord}s. Each NDEF record - has a type such as text, URL, smart poster, or any MIME data. The type of the - first NDEF record in the NDEF message is used to dispatch a tag to an activity - on Android. | + object contains zero or more {@link android.nfc.NdefRecord}s. Each NDEF record has a type + such as text, URL, smart poster, or any MIME data. The type of the first NDEF record in the + NDEF message is used to dispatch a tag to an activity on Android.
| {@link android.nfc.Tag} | -Represents a passive NFC target. These can come in many form factors such as
- a tag, card, key fob, or even a phone doing card emulation. When a tag is
- discovered, a {@link android.nfc.Tag} object is created and wrapped inside an
- Intent. The NFC dispatch system sends the intent to a compatible actvitiy
- using startActivity(). You can use the {@link
- android.nfc.Tag#getTechList getTechList()} method to determine the technologies supported by
- this tag and create the corresponding {@link android.nfc.tech.TagTechnology} object with one
- of classes provided by {@link android.nfc.tech}. |
+ Represents a passive NFC target. These can come in many form factors such as a tag, card,
+ key fob, or even a phone doing card emulation. When a tag is discovered, a {@link
+ android.nfc.Tag} object is created and wrapped inside an Intent. The NFC dispatch system
+ sends the intent to a compatible activity using startActivity(). You can use the
+ {@link android.nfc.Tag#getTechList getTechList()} method to determine the technologies
+ supported by this tag and create the corresponding {@link android.nfc.tech.TagTechnology}
+ object with one of classes provided by {@link android.nfc.tech}. |
The {@link android.nfc.tech} package contains classes to query properties - and perform I/O operations on a tag. The classes are divided to represent different - NFC technologies that can be available on a tag. -
The {@link android.nfc.tech} package contains classes to query properties and perform I/O operations on a tag. The classes are divided to represent different NFC technologies that can be available on a Tag:
@@ -165,28 +154,28 @@ page.title=Near Field Communication
+ limited tag dispatch via {@link android.nfc.NfcAdapter#ACTION_TAG_DISCOVERED}, and only gives
+ access to NDEF messages via the {@link android.nfc.NfcAdapter#EXTRA_NDEF_MESSAGES} extra. No
+ other tag properties or I/O operations are accessible. You probably want to use API level 10
+ which includes comprehensive reader/writer support.
+
<uses-sdk android:minSdkVersion="10"/>
When an Android device scans an NFC tag, the desired behavior is to have the most appropriate - Activity handle the intent without asking the user what appplication to use. Because devices scan + Activity handle the intent without asking the user what application to use. Because devices scan NFC tags at a very short range, it is likely that making users manually select an Activity forces them to move the device away from the tag and break the connection. You should develop your Activity to only handle the NFC tags that your Activity cares about to prevent the Activity @@ -314,12 +302,18 @@ page.title=Near Field Communication
If your Activity declares the android.nfc.action.TECH_DISCOVERED intent in your
AndroidManifest.xml file, you must create an XML resource file that specifies the
- technologies that your Activity supports. The following sample defines all of the technologies.
- Specifiying multiple technologies within the same list tells the system
- to filter tags that support all of the technologies. The example below never filters a tag
- because no tag supports all of the technologies at once.
- You can remove the ones that you do not need. Save this file (you can name it anything you wish)
- in the <project-root>/res/xml folder.
tech-list set. Your Activity is
+ considered a match if a tech-list set is a subset of the technologies that are
+ supported by the tag, which you can obtain by calling {@link android.nfc.Tag#getTechList
+ getTechList()}.
+
+ For example, if the tag that is scanned supports MifareClassic, NdefFormatable, and NfcA, your
+ tech-list set must specify all three, two, or one of the technologies (and nothing
+ else) in order for your Activity to be matched.
The following sample defines all of the technologies. You can remove the ones that you do not
+ need. Save this file (you can name it anything you wish) in the
+ <project-root>/res/xml folder.
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
@@ -336,12 +330,13 @@ page.title=Near Field Communication
</resources>
-You can also specify multiple filter lists. In this case, a tag must match all of the
-technologies within one of the lists. The following example filters for
-cards that support the NfcA and Ndef technology or support the
-NfcB and Ndef technology.
-
-+You can also specify multiple
+tech-listsets. Each of thetech-list+ sets is considered independently, and your Activity is considered a match if any single +tech-listset is a subset of the technologies that are returned by {@link + android.nfc.Tag#getTechList getTechList()}. This providesANDandOR+ semantics for matching technologies. The following example matches tags that can support the + NfcA and Ndef technologies or can support the NfcB and Ndef technologies:<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.NfcA</tech> @@ -358,14 +353,19 @@ NfcB and Ndef technology.In your
AndroidManifest.xmlfile, specify the resource file that you just created - in the<meta-data>element inside the<intent-filter>+ in the<meta-data>element inside the<activity>element like in the following example:+<activity> +... <intent-filter> <action android:name="android.nfc.action.TECH_DISCOVERED"/> - <meta-data android:name="android.nfc.action.TECH_DISCOVERED" - android:resource="@xml/nfc_tech_filter.xml" /> </intent-filter> + +<meta-data android:name="android.nfc.action.TECH_DISCOVERED" + android:resource="@xml/nfc_tech_filter" /> +... +</activity>Using the foreground dispatch system
@@ -391,9 +391,9 @@ PendingIntent pendingIntent = PendingIntent.getActivity( dispatch system checks the specified intent filters with the intent that is received when the device scans a tag. If they match, then your application handles the intent. If it does not match, the foreground dispatch system falls back to the intent dispatch system. - Specifying anullarray of intent filters and for the technology filters, - you receive aTAG_DISCOVEREDintent for all tags discovered. Note that the - snippet below handles all MIME types. You should only handle the ones that you need. + Specifying anullarray of intent filters and for the technology filters, you + receive aTAG_DISCOVEREDintent for all tags discovered. Note that the snippet + below handles all MIME types. You should only handle the ones that you need.IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { @@ -424,7 +424,7 @@ PendingIntent pendingIntent = PendingIntent.getActivity(
Data on NFC tags are encoded in raw bytes, so you must convert the bytes to something human readable if you are presenting the data to the user. When writing to NFC tags, you must write @@ -462,7 +462,7 @@ public void onNewIntent(Intent intent) { Android NFC devices if you are writing to tags. However, many tag technologies use their own standard for storing data and are supported by Android as well, but you have to implement your own protocol stack to read and write to these tags. You can find a full list of the supported - technologies in {@link android.nfc.tech} and an overview of the technolgies in the {@link + technologies in {@link android.nfc.tech} and an overview of the technologies in the {@link android.nfc.tech.TagTechnology} interface. This section is a brief overview of how to work with NDEF messages in the context of the Android system. It is not meant to be a complete discussion of the NDEF specification, but highlights the main things that you need to be aware of when @@ -477,8 +477,8 @@ public void onNewIntent(Intent intent) { {@link android.nfc.NdefMessage}. The size constraint of the NFC tag determines how big your {@link android.nfc.NdefMessage} can be.
-Tags that support the {@link android.nfc.tech.Ndef} and {@link android.nfc.tech.NdefFormatable} - technologies return and accept {@link android.nfc.NdefMessage} +
Tags that support the {@link android.nfc.tech.Ndef} and {@link + android.nfc.tech.NdefFormatable} technologies return and accept {@link android.nfc.NdefMessage} objects as parameters for read and write operations. You need to create your own logic to read and write bytes for other tag technologies in {@link android.nfc.tech}.
@@ -488,7 +488,7 @@ public void onNewIntent(Intent intent) { "{@docRoot}resources/samples/NFCDemo/src/com/example/android/nfc/simulator/MockNdefMessages.html"> plain text and SmartPoster NDEF messages. -When a device comes in proximity to an NFC tag, the appropriate intent is started on the
device, notifying interested applications that a NFC tag was scanned. By previously declaring the
@@ -532,7 +532,7 @@ NdefMessage[] getNdefMessages(Intent intent) {
com.example.android.nfc.record of the NFCDemo sample show you how to parse some
common types of NDEF messages such as plain text or a SmartPoster.
Writing to an NFC tag involves constructing your NDEF message in bytes and using the appropriate tag technology for the tag that you are writing to. The following code sample shows @@ -558,7 +558,7 @@ catch (Exception e){ } -
Support for simple peer-to-peer data exchange is supported by the foreground push feature, which is enabled with the {@link android.nfc.NfcAdapter#enableForegroundNdefPush} method. To use @@ -572,7 +572,6 @@ catch (Exception e){
com.android.npp NDEF push protocol, which is optional for Android devices.If your Activity enables the foreground push feature and is in the foreground, @@ -610,4 +609,4 @@ public void onPause() {
When the Activity is in the foreground, you can now tap the device to another device and push the data to it. See the ForegroundNdefPush - sample in API Demos for a simple example of peer-to-peer data exchange.
+ sample in API Demos for a simple example of peer-to-peer data exchange. \ No newline at end of file