public final class

NdefMessage

extends Object
implements Parcelable
java.lang.Object
   ↳ android.nfc.NdefMessage

Class Overview

Represents an NDEF (NFC Data Exchange Format) data message that contains one or more NdefRecords.

An NDEF message includes "records" that can contain different sets of data, such as MIME-type media, a URI, or one of the supported RTD types (see NdefRecord). An NDEF message always contains zero or more NDEF records.

This is an immutable data class.

Summary

Constants
Creator<NdefMessage> CREATOR
[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Constructors
NdefMessage(byte[] data)
Create an NDEF message from raw bytes.
NdefMessage(NdefRecord[] records)
Create an NDEF message from NDEF records.
Public Methods
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
NdefRecord[] getRecords()
Get the NDEF records inside this NDEF message.
byte[] toByteArray()
Returns a byte array representation of this entire NDEF message.
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final Creator<NdefMessage> CREATOR

Since: API Level 9

Public Constructors

public NdefMessage (byte[] data)

Since: API Level 9

Create an NDEF message from raw bytes.

Validation is performed to make sure the Record format headers are valid, and the ID + TYPE + PAYLOAD fields are of the correct size.

public NdefMessage (NdefRecord[] records)

Since: API Level 9

Create an NDEF message from NDEF records.

Public Methods

public int describeContents ()

Since: API Level 9

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public NdefRecord[] getRecords ()

Since: API Level 9

Get the NDEF records inside this NDEF message.

Returns
  • array of zero or more NDEF records.

public byte[] toByteArray ()

Since: API Level 9

Returns a byte array representation of this entire NDEF message.

public void writeToParcel (Parcel dest, int flags)

Since: API Level 9

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.