Java android.nfc NdefRecord fields, constructors, methods, implement or subclass

Example usage for Java android.nfc NdefRecord fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.nfc NdefRecord.

The text is from its open source code.

Field

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

Use this tnf with RTD types such as #RTD_TEXT , #RTD_URI .

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

Use this with MIME type names such as "image/jpeg" , or using the helper #createMime .

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

When creating new records prefer #createUri , since it offers more compact URI encoding ( #RTD_URI allows compression of common URI prefixes).

shortTNF_EXTERNAL_TYPE
Indicates the type field contains an external type name.

Used to encode custom payloads.

shortTNF_UNKNOWN
Indicates the payload type is unknown.

NFC Forum explains this should be treated similarly to the "application/octet-stream" MIME type.

nullRTD_TEXT
RTD Text type.
nullRTD_URI
RTD URI type.
nullRTD_HANDOVER_REQUEST
RTD Handover Request type.

Constructor

NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload)
Construct an NDEF Record from its component fields.

Recommend to use helpers such as {#createUri} or { #createExternal where possible, since they perform stricter validation that the record is correctly formatted as per NDEF specifications.

Method

NdefRecordcreateApplicationRecord(String packageName)
Create a new Android Application Record (AAR).
NdefRecordcreateExternal(String domain, String type, byte[] data)
Create a new NDEF Record containing external (application-specific) data.

Use this method to encode application specific data into an NDEF Record.

NdefRecordcreateMime(String mimeType, byte[] mimeData)
Create a new NDEF Record containing MIME data.

Use this method to encode MIME-typed data into an NDEF Record, such as "text/plain", or "image/jpeg".

The mimeType parameter will be normalized with Intent#normalizeMimeType to follow Android best practices for intent filtering, for example to force lower-case.

NdefRecordcreateUri(Uri uri)
Create a new NDEF Record containing a URI.

Use this method to encode a URI (or URL) into an NDEF Record.

Uses the well known URI type representation: #TNF_WELL_KNOWN and #RTD_URI .

NdefRecordcreateUri(String uriString)
Create a new NDEF Record containing a URI.

Use this method to encode a URI (or URL) into an NDEF Record.

Uses the well known URI type representation: #TNF_WELL_KNOWN and #RTD_URI .

byte[]getId()
Returns the variable length ID.
byte[]getPayload()
Returns the variable length payload.
shortgetTnf()
Returns the 3-bit TNF.
byte[]getType()
Returns the variable length Type field.
byte[]toByteArray()
Return this NDEF Record as a byte array.

This method is deprecated, use NdefMessage#toByteArray instead.

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

Currently this method considers the following to be URI records:

  • #TNF_ABSOLUTE_URI records.
  • #TNF_WELL_KNOWN with a type of #RTD_URI .
  • #TNF_WELL_KNOWN with a type of #RTD_SMART_POSTER and containing a URI record in the NDEF message nested in the payload.