看一下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.Here's a summary of the classes:NfcManagerThis is the high level manager, used to obtain this device's NfcAdapter. You can acquire an instance using getSystemService(String).NfcAdapterThis 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).NdefMessageRepresents 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.NdefRecordRepresents 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模块就不需要了? (待验证)