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.