Android.Nfc.NdefRecord Class
Represents an immutable NDEF Record.

See Also: NdefRecord Members

Syntax

[Android.Runtime.Register("android/nfc/NdefRecord", DoNotGenerateAcw=true)]
public sealed class NdefRecord : Java.Lang.Object, Android.OS.IParcelable, IDisposable

Remarks

Represents an immutable NDEF Record.

NDEF (NFC Data Exchange Format) is a light-weight binary format, used to encapsulate typed data. It is specified by the NFC Forum, for transmission and storage with NFC, however it is transport agnostic.

NDEF defines messages and records. An NDEF Record contains typed data, such as MIME-type media, a URI, or a custom application payload. An NDEF Message is a container for one or more NDEF Records.

This class represents logical (complete) NDEF Records, and can not be used to represent chunked (partial) NDEF Records. However NdefMessage(Byte[]) can be used to parse a message containing chunked records, and will return a message with unchunked (complete) records.

A logical NDEF Record always contains a 3-bit TNF (Type Name Field) that provides high level typing for the rest of the record. The remaining fields are variable length and not always present:

Helpers such as NdefRecord.CreateUri(Android.Net.Uri), NdefRecord.CreateMime(string, System.Byte[]) and NdefRecord.CreateExternal(string, System.String, System.String) are included to create well-formatted NDEF Records with correctly set tnf, type, id and payload fields, please use these helpers whenever possible.

Use the constructor NdefRecord(short, System.Byte[], System.Byte[], System.Byte[]) if you know what you are doing and what to set the fields individually. Only basic validation is performed with this constructor, so it is possible to create records that do not confirm to the strict NFC Forum specifications.

The binary representation of an NDEF Record includes additional flags to indicate location with an NDEF message, provide support for chunking of NDEF records, and to pack optional fields. This class does not expose those details. To write an NDEF Record as binary you must first put it into an Android.Nfc.NdefMessage, then call NdefMessage.ToByteArray.

Android.Nfc.NdefMessage and Android.Nfc.NdefRecord implementations are always available, even on Android devices that do not have NFC hardware.

Android.Nfc.NdefRecords are intended to be immutable (and thread-safe), however they may contain mutable fields. So take care not to modify mutable fields passed into constructors, or modify mutable fields obtained by getter methods, unless such modification is explicitly marked as safe.

See Also

[Android Documentation]

Requirements

Namespace: Android.Nfc
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 9