summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2011-08-05 10:41:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-05 10:41:10 -0700
commite29ea093281a50da8419fb68ca627bfa5e4df190 (patch)
tree2932aeaa59f06a128d9f2a9bdb839817159520f9 /core/java
parentb83316f8c8a98ae95404abaea9dde010f66d58c5 (diff)
parenta37fcbce59c8a746f641936b4de99867dbfabac9 (diff)
Merge "Add Android app RTD type and convenience method."
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/nfc/NdefRecord.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index b668f3073602..6ba34515c9f0 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -21,6 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import java.lang.UnsupportedOperationException;
+import java.nio.charset.Charset;
import java.nio.charset.Charsets;
import java.util.Arrays;
@@ -139,6 +140,22 @@ public final class NdefRecord implements Parcelable {
*/
public static final byte[] RTD_HANDOVER_SELECT = {0x48, 0x73}; // "Hs"
+ /**
+ * RTD Android app type. For use with TNF_EXTERNAL.
+ * <p>
+ * The payload of a record with type RTD_ANDROID_APP
+ * should be the package name identifying an application.
+ * Multiple RTD_ANDROID_APP records may be included
+ * in a single {@link NdefMessage}.
+ * <p>
+ * Use {@link #createApplicationRecord(String)} to create
+ * RTD_ANDROID_APP records.
+ * @hide
+ */
+ // TODO unhide for ICS
+ // TODO recheck docs
+ public static final byte[] RTD_ANDROID_APP = "android.com:pkg".getBytes();
+
private static final byte FLAG_MB = (byte) 0x80;
private static final byte FLAG_ME = (byte) 0x40;
private static final byte FLAG_CF = (byte) 0x20;
@@ -333,6 +350,29 @@ public final class NdefRecord implements Parcelable {
}
/**
+ * Creates an Android application NDEF record.
+ * <p>
+ * When an Android device dispatches an {@link 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 {@link NdefMessage}.
+ * <p>
+ * If none of the applications are installed on the device,
+ * a Market link will be opened to the first application.
+ * <p>
+ * Note that Android application records do not overrule
+ * applications that have called {@link NfcAdapter#enableForegroundDispatch}.
+ * @hide
+ */
+ // TODO unhide for ICS
+ // TODO recheck javadoc - should mention this works from ICS only
+ public static NdefRecord createApplicationRecord(String packageName) {
+ return new NdefRecord(TNF_EXTERNAL_TYPE, RTD_ANDROID_APP, new byte[] {},
+ packageName.getBytes(Charsets.US_ASCII));
+ }
+
+ /**
* Creates an NDEF record of well known type URI.
*/
public static NdefRecord createUri(Uri uri) {