diff options
| author | Nick Pelly <npelly@google.com> | 2012-01-09 10:48:28 -0800 |
|---|---|---|
| committer | Nick Pelly <npelly@google.com> | 2012-01-25 13:16:52 -0800 |
| commit | a983c2a1a39cd4829594f19fd9d0d2070cd0cc71 (patch) | |
| tree | 84ddd3b0e8daa5139f310a9f802c56129e333c0f /samples/AndroidBeamDemo | |
| parent | 3c407385303dc44906342147368451f2ef528cff (diff) | |
| download | android_development-a983c2a1a39cd4829594f19fd9d0d2070cd0cc71.tar.gz android_development-a983c2a1a39cd4829594f19fd9d0d2070cd0cc71.tar.bz2 android_development-a983c2a1a39cd4829594f19fd9d0d2070cd0cc71.zip | |
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
Diffstat (limited to 'samples/AndroidBeamDemo')
| -rw-r--r-- | samples/AndroidBeamDemo/Android.mk | 2 | ||||
| -rw-r--r-- | samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java | 19 |
2 files changed, 4 insertions, 17 deletions
diff --git a/samples/AndroidBeamDemo/Android.mk b/samples/AndroidBeamDemo/Android.mk index f125f0f6c..b5f45e864 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 0cc5f899f..d419bacbe 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 @@ public class Beam extends Activity implements CreateNdefMessageCallback, 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 @@ public class Beam extends Activity implements CreateNdefMessageCallback, * uses the tag dispatch system. */ //,NdefRecord.createApplicationRecord("com.example.android.beam") - }); + ); return msg; } @@ -138,18 +137,6 @@ public class Beam extends Activity implements CreateNdefMessageCallback, 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 |
