@Override public NdefMessage createNdefMessage(final NfcEvent event) { NdefRecord[] records; if (mPermalink == null) { // no permalink yet, just provide AAR records = new NdefRecord[] {NdefRecord.createApplicationRecord(getPackageName())}; } else { records = new NdefRecord[] { NdefRecord.createUri(mPermalink), NdefRecord.createApplicationRecord(getPackageName()) }; } return new NdefMessage(records); }
public NdefMessage createNdefMessage() { return new NdefMessage( new NdefRecord[] { createMime( Constants.TAG_WRITER_MIME_TYPE, new Gson().toJson(createdDrinkerFromUserInput()).getBytes()), NdefRecord.createApplicationRecord(Constants.DRINKER_STATION_APP_RECORD) }); }
@Override public NdefMessage createNdefMessage(NfcEvent event) { // android.os.Build.SERIAL is sent to the other device to be paired String text = (android.os.Build.SERIAL + "," + userName); NdefMessage msg = new NdefMessage( new NdefRecord[] { createMimeRecord("application/edu.temple.encryptedfiletransfer", text.getBytes()), NdefRecord.createApplicationRecord("edu.temple.encryptedfiletransfer") }); return msg; }
@Override public NdefMessage createNdefMessage(NfcEvent arg0) { NdefRecord uriRecord = new NdefRecord( NdefRecord.TNF_MIME_MEDIA, MIME_TYPE.getBytes(Charset.forName("US-ASCII")), new byte[0], beamFragment.getUrl().getBytes(Charset.forName("US-ASCII"))); NdefMessage msg = new NdefMessage( new NdefRecord[] { uriRecord, NdefRecord.createApplicationRecord("com.commonsware.android.webbeam") }); return (msg); }
public NdefMessage getTagAsNdef() { boolean addAAR = false; byte[] uriField = uniqueId.getBytes(Charset.forName("US-ASCII")); byte[] payload = new byte[uriField.length + 1]; // add 1 for the URI Prefix payload[0] = 0x01; // prefixes http://www. to the URI System.arraycopy(uriField, 0, payload, 1, uriField.length); // appends URI to payload NdefRecord rtdUriRecord = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload); if (addAAR) { // note: returns AAR for different app (nfcreadtag) return new NdefMessage( new NdefRecord[] { rtdUriRecord, NdefRecord.createApplicationRecord("com.mig.cpsudev.theblackgate") }); } else { return new NdefMessage(new NdefRecord[] {rtdUriRecord}); } }
/** * Creates records to send to another device if detected those records are about to send to * another device * * @return NdefRecord[] - array of records to attach */ public NdefRecord[] createRecords() { NdefRecord[] records = new NdefRecord[messagesToSendQueue.size()]; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { for (int counter = 0; counter < messagesToSendQueue.size(); counter++) { byte[] payload = messagesToSendQueue.get(counter).getBytes(Charset.forName("UTF-8")); NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], payload); records[counter] = record; } } else { for (int counter = 0; counter < messagesToSendQueue.size(); counter++) { byte[] payload = messagesToSendQueue.get(counter).getBytes(Charset.forName("UTF-8")); NdefRecord record = NdefRecord.createMime("text/plain", payload); records[counter] = record; } } records[messagesToSendQueue.size()] = NdefRecord.createApplicationRecord(getPackageName()); return records; }