【Android 2.3 & 2.3.3】 近距離無線通訊NFC API

來源:互聯網
上載者:User

看一下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模組就不需要了? (待驗證)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.