看一下android2.3的api,如:
從這邊的介紹可以看出,Android2.3 提供了NFC的訪問功能,允許應用讀取NFC tags中的NDEF訊息。
可以看到, Android2.3 新增了android.nfc 這個包。 下面一共就三個類. 實際上, 不止三個類, 還有兩個隱藏類。 如:
下面看下這幾個公開類的作用:
NfcAdapter:這個代表裝置NFC功能的適配器,也就是執行NFC操作的如何。
NdefMessage:代表一個NDEF資料格式的訊息,承載了很多記錄。
NdefRecord:代表上面的NdefMessage中內含的一個記錄。
應該說是比較的簡單, 還很不完善。
下面再看下Android 2.3.3中對NFC 的支援,如:
可以很明顯的看到,這邊多了兩個類。
再看看其介紹:
Provides access to Near Field Communication (NFC) functionality, allowing applications to read NDEF message in NFC tags. A "tag" may actually be another device that appears as a tag.<br />Here's a summary of the classes:<br />NfcManager<br />This is the high level manager, used to obtain this device's NfcAdapter. You can acquire an instance using getSystemService(String).<br />NfcAdapter<br />This represents the device's NFC adapter, which is your entry-point to performing NFC operations. You can acquire an instance with getDefaultAdapter(), or getDefaultAdapter(android.content.Context).<br />NdefMessage<br />Represents an NDEF data message, which is the standard format in which "records" carrying data are transmitted between devices and tags. Your application can receive these messages from an ACTION_TAG_DISCOVERED intent.<br />NdefRecord<br />Represents a record, which is delivered in a NdefMessage and describes the type of data being shared and carries the data itself.
這邊就不多囉嗦了。更多關於Android 2.3.3 中NFC的介紹,看這裡: http://blog.csdn.net/nicebooks/archive/2011/03/04/6223956.aspx
寫的很不錯!特此推薦!
NFC在Android代碼中的位置:
1. frameworks/base/core/java/android/nfc
2. frameworks/base/core/java/android/nfc/tech
下次有空再研究!
想瞭解更多關於NFC的知識, 請到這裡: http://www.nfc-forum.org/home/
NXP: http://www.nxp.com/theme/nfc/
另外還有個NFC開源API: http://www.open-nfc.org/ 提供了對Android的支援, 有了它,是不是Android提供的NFC模組就不需要了? (待驗證)