/**
* Starts emulating an NDEF tag with hardcoded payloads
*/
public void startNDEFEmulation() {
// Create the NDEFMessage that will contain the NDEFRecords
final NDEFMessage ndefMessage = new NDEFMessage();
// Begin creating the NDEFRecords with "text/plain" payloads
final NDEFRecord rec1 = new NDEFRecord();
rec1.setId("1");
try {
rec1.setType(NDEFRecord.TNF_MEDIA, "text/plain");
} catch (final NFCException e) {
_screen.add(new LabelField("Error: " + e.toString()));
}
rec1.setPayload("I am the 1st payload".getBytes());
final NDEFRecord rec2 = new NDEFRecord();
rec2.setId("2");
try {
rec2.setType(NDEFRecord.TNF_MEDIA, "text/plain");
} catch (final NFCException e) {
_screen.add(new LabelField("Error: " + e.toString()));
}
rec2.setPayload("I am the 2nd payload".getBytes());
ndefMessage.setRecords(new NDEFRecord[] { rec1, rec2 });
// Create the VirtualNDEFTag to be emulated
_ndefVirtualTarget =
new VirtualNDEFTag(ndefMessage, new VirtualNDEFTagListener(
_screen));