手机版

Android NFC framework introduction and develop guide(3)

发布时间:2021-06-07   来源:未知    
字号:

Android system NFC framework introduction and develop guide

Now that you have some background in NFC tags, the following sections describe in more detail how Android handles NDEF formatted tags. When an Android-powered device scans an NFC tag containing NDEF formatted data, it parses the message and tries to figure out the data's MIME type or identifying URI. To do this, the system reads the first NdefRecord inside the NdefMessage to determine how to interpret the entire NDEF message (an NDEF message can have multiple NDEF records). In a well-formed NDEF message, the first NdefRecord contains the following fields:

3-bit TNF (Type Name Format)

Indicates how to interpret the variable length

type field. Valid values are described in Variable length type

Describes the type of the record. If using TNF_WELL_KNOWN, use this field to specify the

Record Type Definition (RTD). Valid RTD Variable length ID

A unique identifier for the record. This field is

not used often, but if you need to uniquely

identify a tag, you can create an ID for it.

Variable length payload

The actual data payload that you want to read

or write. An NDEF message can contain

multiple NDEF records, so don't assume the

full payload is in the first NDEF record of the

NDEF message.

The tag dispatch system uses the TNF and type fields to try to map a MIME type or URI to the NDEF message. If successful, it encapsulates that information inside of a ACTION_NDEF_DISCOVERED intent along with the actual payload. However, there are cases when the tag dispatch system cannot determine the type of data based on the first NDEF record. This happens when the NDEF data cannot be mapped to a MIME type or URI, or when the NFC tag does not contain NDEF data to begin with. In such cases, a Tag object that has information about the tag's technologies and the payload are encapsulated inside of a ACTION_TECH_DISCOVERED intent instead.

Android NFC framework introduction and develop guide(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)