Update NFC samples.
o Remove NFCDemo sample app. It's janky and is mostly parsing code
that isn't needed anymore.
o Use new NDEF APIs for parsing and creating records
o Use nicer setNdefPushMessage() API
o Delete helper NDEF code that is not needed any more
o Use URL instead of Text for the foreground push demo
o Mark AndroidBeamDemo a test so it gets installed in data not system
Change-Id: I75eda84019c2075956688e26f2598f126d5659a2
diff --git a/samples/AndroidBeamDemo/Android.mk b/samples/AndroidBeamDemo/Android.mk
index f125f0f..b5f45e8 100644
--- a/samples/AndroidBeamDemo/Android.mk
+++ b/samples/AndroidBeamDemo/Android.mk
@@ -1,7 +1,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := samples
+LOCAL_MODULE_TAGS := samples tests
# Only compile source java files in this apk.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java b/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
index 0cc5f89..d419bac 100644
--- a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
+++ b/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
@@ -73,9 +73,8 @@
time.setToNow();
String text = ("Beam me up!\n\n" +
"Beam Time: " + time.format("%H:%M:%S"));
- NdefMessage msg = new NdefMessage(
- new NdefRecord[] { createMimeRecord(
- "application/com.example.android.beam", text.getBytes())
+ NdefMessage msg = new NdefMessage(NdefRecord.createMime(
+ "application/com.example.android.beam", text.getBytes())
/**
* The Android Application Record (AAR) is commented out. When a device
* receives a push with an AAR in it, the application specified in the AAR
@@ -85,7 +84,7 @@
* uses the tag dispatch system.
*/
//,NdefRecord.createApplicationRecord("com.example.android.beam")
- });
+ );
return msg;
}
@@ -138,18 +137,6 @@
mInfoText.setText(new String(msg.getRecords()[0].getPayload()));
}
- /**
- * Creates a custom MIME type encapsulated in an NDEF record
- *
- * @param mimeType
- */
- public NdefRecord createMimeRecord(String mimeType, byte[] payload) {
- byte[] mimeBytes = mimeType.getBytes(Charset.forName("US-ASCII"));
- NdefRecord mimeRecord = new NdefRecord(
- NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], payload);
- return mimeRecord;
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// If NFC is not available, we won't be needing this menu