blob: 07978f23cf446ef46c391521332bc4ac394a0bf4 [file] [log] [blame]
Megha Joshi6aa608a2010-11-02 23:27:24 -07001<p>
2 Near-field Communication or NFC is a standard defined by the
3 <a href=http://www.nfc-forum.org/home>NFC Forum
4 </a>.
5 NFC Data Exchange Format (NDEF) defines a common data format between NFC-compliant devices and tags.
6 This demo application shows how to read a NDEF Tags using using Android 2.3 SDK APIs.
7 The NFC Tags consist of data encoded in NDEF Message format specified by NFC Forum Type 2 Specification.
8 Each NDEF message consists of one or more NDEF Records.
9
10 You need a NFC compliant device and a NFC compliant Tag to use this sample app. Or else, you could use
11 the FakeTagsActivity displayed at launch of this sample app, to generate fake Tag broadcasts from the emulator.
12</p>
13
14<p>The application includes:
15</p>
16 <ul>
17 <li>
18 <a href="src/com/example/android/nfc/TagViewer.html">
19 <code>TagViewer
20 </code>
21 </a>
22 &mdash; an
23 <code>Activity
24 </code> that handles a broadcast of a new tag that the device
25 just discovered, parses it, and displays its record contents in a
26 <code>ListActivity
27 </code>
28 </li>
29 <li>
30 <a href="src/com/example/android/nfc/NdefMessageParser.html">
31 <code> NdefMessageParser
32 </code>
33 </a>
34 &mdash; parses the record type of records within the NDEF message.
35 </li>
36 <li>
37 <a href="src/com/example/android/nfc/record/ParsedNdefRecord.html">
38 <code>ParsedNdefRecord
39 </code>
40 </a>
41 &mdash; an interface implemented by all parsed NdefRecord types.
42 </li>
43 <li>
44 <a href="src/com/example/android/nfc/record/SmartPoster.html">
45 <code>SmartPoster
46 </code>
47 </a>
48 &mdash; a representation of an NFC Forum Smart Poster Record Type.
49 </li>
50 <li>
51 <a href="src/com/example/android/nfc/record/TextRecord.html">
52 <code>TextRecord
53 </code>
54 </a>
55 &mdash; a representation of an NFC Forum Text Record Type.
56 </li>
57 <li>
58 <a href="src/com/example/android/nfc/record/UriRecord.html">
59 <code>UriRecord
60 </code>
61 </a>
62 &mdash; a representation of an NFC Forum Uri Record Type.
63 </li>
64 <li>
65 <a href="src/com/example/android/nfc/simulator/FakeTagsActivity.html">
66 <code>FakeTagsActivity
67 </code>
68 </a>
69 &mdash; A activity that launches tags as if they had been scanned.
70 This is useful if you don't have access to NFC enabled device or tag.
71 </li>
72 <li>
73 <a href="src/com/example/android/nfc/simulator/MockNdefMessages.html">
74 <code>MockNdefMessages
75 </code>
76 </a>
77 &mdash; this class provides a list of fake NFC Ndef format Tags.
78 </li>
79
80 </ul>
81<p>If you are developing an application that uses the NFC API, remember that the feature
82 is supported only on Android 2.3 (API level 9) and higher versions of the platform. Also,
83 among devices running Android 2.3 (API level 9) or higher, not all devices will offer NFC
84 support. To ensure that your application can only be installed on devices that are capable
85 of supporting NFC, remember to add the following to the application's manifest before
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080086 publishing to Google Play:
Megha Joshi6aa608a2010-11-02 23:27:24 -070087</p>
88<ul>
89 <li>
90 <code>&lt;uses-sdk android:minSdkVersion="9" /&gt;
91 </code>,
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080092 which indicates to Google Play and the platform that your application requires
Megha Joshi6aa608a2010-11-02 23:27:24 -070093 Android 2.3 or higher. For more information, see
94 <a href="../../../guide/appendix/api-levels.html">API Levels
95 </a>
96 and the documentation for the
97 <a href="../../../guide/topics/manifest/uses-sdk-element.html">
98 <code>&lt;uses-sdk&gt;
99 </code>
100 </a> element.
101 </li>
102</ul>
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -0800103<p>To control how Google Play filters your application
Megha Joshi6aa608a2010-11-02 23:27:24 -0700104 from devices that do not support NFC, remember to add the following to the application's manifest
105 <ul>
106 <li>
107 <code>&lt;uses-feature android:name="android.hardware.nfc" /&gt;
108 </code>,
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -0800109 which tells Google Play that your application uses the NFC API. The declaration
Megha Joshi6aa608a2010-11-02 23:27:24 -0700110 should include an
111 <code>android:required
112 </code> attribute that indicates whether you want
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -0800113 Google Play to filter the application from devices that do not offer NFC support. Other
Megha Joshi6aa608a2010-11-02 23:27:24 -0700114 <code>&lt;uses-feature&gt;
115 </code> declarations may also be needed, depending on your
116 implementation. For more information, see the documentation for the
117 <a href="../../../guide/topics/manifest/uses-feature-element.html">
118 <code>&lt;uses-feature&gt;
119 </code>
120 </a> element.
121 </li>
122 </ul>
123<p>For more information about using the NFC API, see the
124 <a href="../../../reference/android/nfc/package-summary.html">
125 <code>android.nfc</code>
126 </a>
127 documentation.
128</p>
129<img alt="" src="../images/NfcDemo.png"/>