public class

NdefFactory

extends Object
java.lang.Object
   ↳ mobisocial.nfc.NdefFactory

Class Overview

A utility class for generating NDEF messages.

See Also

Summary

Fields
public static final byte[] RTD_ANDROID_APP An RTD indicating an Android Application Record.
Public Constructors
NdefFactory()
Public Methods
static NdefRecord createApplicationRecord(String packageName)

From Android SDK, version 14.

static NdefMessage fromMime(String mimeType, byte[] data)
static NdefMessage fromText(String text, String languageCode)
Creates an NDEF message with a single text record, with the given text content (UTF-8 encoded) and language code.
static NdefMessage fromText(String text)
Creates an NDEF message with a single text record, with language code "en" and the given text, encoded using UTF-8.
static NdefMessage fromUri(Uri uri)
static NdefMessage fromUri(String uri)
static NdefMessage fromUri(URI uri)
static NdefMessage fromUrl(URL url)
final static NdefMessage getEmptyNdef()
final static boolean isEmpty(NdefMessage ndef)
final static Uri parseUri(NdefRecord record)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final byte[] RTD_ANDROID_APP

An RTD indicating an Android Application Record.

Public Constructors

public NdefFactory ()

Public Methods

public static NdefRecord createApplicationRecord (String packageName)

From Android SDK, version 14. (C) 2010 The Android Open Source Project

Creates an Android application NDEF record.

This record indicates to other Android devices the package that should be used to handle the rest of the NDEF message. You can embed this record anywhere into your NDEF message to ensure that the intended package receives the message.

When an Android device dispatches an NdefMessage containing one or more Android application records, the applications contained in those records will be the preferred target for the NDEF_DISCOVERED intent, in the order in which they appear in the NdefMessage. This dispatch behavior was first added to Android in Ice Cream Sandwich.

If none of the applications are installed on the device, a Market link will be opened to the first application.

Note that Android application records do not overrule applications that have called NfcAdapter#enableForegroundDispatch.

Parameters
packageName Android package name
Returns
  • Android application NDEF record

public static NdefMessage fromMime (String mimeType, byte[] data)

public static NdefMessage fromText (String text, String languageCode)

Creates an NDEF message with a single text record, with the given text content (UTF-8 encoded) and language code.

public static NdefMessage fromText (String text)

Creates an NDEF message with a single text record, with language code "en" and the given text, encoded using UTF-8.

public static NdefMessage fromUri (Uri uri)

public static NdefMessage fromUri (String uri)

public static NdefMessage fromUri (URI uri)

public static NdefMessage fromUrl (URL url)

public static final NdefMessage getEmptyNdef ()

public static final boolean isEmpty (NdefMessage ndef)

public static final Uri parseUri (NdefRecord record)