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文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219