java.lang.Object | |
↳ | android.nfc.NdefRecord |
Represents a logical (unchunked) NDEF (NFC Data Exchange Format) record.
An NDEF record always contains:
The underlying record representation may be chunked across several NDEF records when the payload is large.
This is an immutable data class.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
short | TNF_ABSOLUTE_URI | Indicates the type field contains a value that follows the absolute-URI BNF construct defined by RFC 3986. | |||||||||
short | TNF_EMPTY | Indicates no type, id, or payload is associated with this NDEF Record. | |||||||||
short | TNF_EXTERNAL_TYPE | Indicates the type field contains a value that follows the RTD external name specification. | |||||||||
short | TNF_MIME_MEDIA | Indicates the type field contains a value that follows the media-type BNF construct defined by RFC 2046. | |||||||||
short | TNF_UNCHANGED | Indicates the payload is an intermediate or final chunk of a chunked NDEF Record. | |||||||||
short | TNF_UNKNOWN | Indicates the payload type is unknown. | |||||||||
short | TNF_WELL_KNOWN | Indicates the type field uses the RTD type name format. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR | |||||||||||
RTD_ALTERNATIVE_CARRIER | RTD Alternative Carrier type. | ||||||||||
RTD_HANDOVER_CARRIER | RTD Handover Carrier type. | ||||||||||
RTD_HANDOVER_REQUEST | RTD Handover Request type. | ||||||||||
RTD_HANDOVER_SELECT | RTD Handover Select type. | ||||||||||
RTD_SMART_POSTER | RTD Smart Poster type. | ||||||||||
RTD_TEXT | RTD Text type. | ||||||||||
RTD_URI | RTD URI type. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct an NDEF Record.
| |||||||||||
Construct an NDEF Record from raw bytes.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the variable length ID.
| |||||||||||
Returns the variable length payload.
| |||||||||||
Returns the 3-bit TNF.
| |||||||||||
Returns the variable length Type field.
| |||||||||||
Returns this entire NDEF Record as a byte array.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
|
Indicates the type field contains a value that follows the absolute-URI BNF construct defined by RFC 3986.
Indicates no type, id, or payload is associated with this NDEF Record.
Type, id and payload fields must all be empty to be a valid TNF_EMPTY record.
Indicates the type field contains a value that follows the RTD external name specification.
Note this TNF should not be used with RTD_TEXT or RTD_URI constants. Those are well known RTD constants, not external RTD constants.
Indicates the type field contains a value that follows the media-type BNF construct defined by RFC 2046.
Indicates the payload is an intermediate or final chunk of a chunked NDEF Record.
The payload type is specified in the first chunk, and subsequent chunks must use TNF_UNCHANGED with an empty type field. TNF_UNCHANGED must not be used in any other situation.
Indicates the payload type is unknown.
This is similar to the "application/octet-stream" MIME type. The payload type is not explicitly encoded within the NDEF Message.
The type field must be empty to be a valid TNF_UNKNOWN record.
Indicates the type field uses the RTD type name format.
Use this TNF with RTD types such as RTD_TEXT, RTD_URI.
RTD Alternative Carrier type. For use with TNF_WELL_KNOWN.
RTD Handover Carrier type. For use with TNF_WELL_KNOWN.
RTD Handover Request type. For use with TNF_WELL_KNOWN.
RTD Handover Select type. For use with TNF_WELL_KNOWN.
RTD Smart Poster type. For use with TNF_WELL_KNOWN.
Construct an NDEF Record.
Applications should not attempt to manually chunk NDEF Records - the implementation of android.nfc will automatically chunk an NDEF Record when necessary (and only present a single logical NDEF Record to the application). So applications should not use TNF_UNCHANGED.
tnf | a 3-bit TNF constant |
---|---|
type | byte array, containing zero to 255 bytes, must not be null |
id | byte array, containing zero to 255 bytes, must not be null |
payload | byte array, containing zero to (2 ** 32 - 1) bytes, must not be null |
Construct an NDEF Record from raw bytes.
Validation is performed to make sure the header is valid, and that the id, type and payload sizes appear to be valid.
FormatException | if the data is not a valid NDEF record |
---|
Returns the variable length Type field.
This should be used in conjunction with the TNF field to determine the payload format.