共用方式為


NdefRecord Class

Definition

Represents an immutable NDEF Record.

[Android.Runtime.Register("android/nfc/NdefRecord", DoNotGenerateAcw=true)]
public sealed class NdefRecord : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/nfc/NdefRecord", DoNotGenerateAcw=true)>]
type NdefRecord = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
NdefRecord
Attributes
Implements

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#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: <ul> <li><em>type</em>: detailed typing for the payload</li> <li><em>id</em>: identifier meta-data, not commonly used</li> <li><em>payload</em>: the actual payload</li> </ul>

Helpers such as NdefRecord#createUri, NdefRecord#createMime and NdefRecord#createExternal 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, byte[], byte[], 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 NdefMessage, then call NdefMessage#toByteArray(). <p class="note"> NdefMessage and NdefRecord implementations are always available, even on Android devices that do not have NFC hardware. <p class="note"> 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.

Java documentation for android.nfc.NdefRecord.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

NdefRecord(Byte[])
Obsolete.

Construct an NDEF Record from raw bytes.

NdefRecord(Int16, Byte[], Byte[], Byte[])

Construct an NDEF Record from its component fields.

Fields

TnfAbsoluteUri

Indicates the type field contains an absolute-URI BNF construct defined by RFC 3986.

TnfEmpty

Indicates the record is empty.

TnfExternalType

Indicates the type field contains an external type name.

TnfMimeMedia

Indicates the type field contains a media-type BNF construct, defined by RFC 2046.

TnfUnchanged

Indicates the payload is an intermediate or final chunk of a chunked NDEF Record.

TnfUnknown

Indicates the payload type is unknown.

TnfWellKnown

Indicates the type field contains a well-known RTD type name.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
RtdAlternativeCarrier

RTD Alternative Carrier type.

RtdHandoverCarrier

RTD Handover Carrier type.

RtdHandoverRequest

RTD Handover Request type.

RtdHandoverSelect

RTD Handover Select type.

RtdSmartPoster

RTD Smart Poster type.

RtdText

RTD Text type.

RtdUri

RTD URI type.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
Tnf

Returns the 3-bit TNF.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CreateApplicationRecord(String)

Create a new Android Application Record (AAR).

CreateExternal(String, String, Byte[])

Create a new NDEF Record containing external (application-specific) data.

CreateMime(String, Byte[])

Create a new NDEF Record containing MIME data.

CreateTextRecord(String, String)

Create a new NDEF record containing UTF-8 text data.

CreateUri(String)

Create a new NDEF Record containing a URI.

CreateUri(Uri)

Create a new NDEF Record containing a URI.

DescribeContents()

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

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetId()

Returns the variable length ID.

GetPayload()

Returns the variable length payload.

GetTypeInfo()

Returns the variable length Type field.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToByteArray()
Obsolete.

Return this NDEF Record as a byte array.

ToMimeType()

Map this record to a MIME type, or return null if it cannot be mapped.

ToString()

Returns a string representation of the object.

(Inherited from Object)
ToUri()

Map this record to a URI, or return null if it cannot be mapped.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to