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
This commit is contained in:
Nick Pelly
2012-01-09 10:48:28 -08:00
parent 3c40738530
commit a983c2a1a3
23 changed files with 10 additions and 1436 deletions

View File

@@ -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