Java Code Examples for android.nfc.NdefRecord#RTD_URI
The following examples show how to use
android.nfc.NdefRecord#RTD_URI .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WriteUriActivity.java From android-nfc with MIT License | 6 votes |
/** * 将Uri转成NdefRecord * * @param uriStr * @return */ public static NdefRecord createUriRecord(String uriStr) { byte prefix = 0; for (Byte b : UriPrefix.URI_PREFIX_MAP.keySet()) { String prefixStr = UriPrefix.URI_PREFIX_MAP.get(b).toLowerCase(); if ("".equals(prefixStr)) continue; if (uriStr.toLowerCase().startsWith(prefixStr)) { prefix = b; uriStr = uriStr.substring(prefixStr.length()); break; } } byte[] data = new byte[1 + uriStr.length()]; data[0] = prefix; System.arraycopy(uriStr.getBytes(), 0, data, 1, uriStr.length()); NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], data); return record; }
Example 2
Source File: NfcManager.java From nfcard with GNU General Public License v3.0 | 3 votes |
NdefMessage createNdefMessage() { String uri = "3play.google.com/store/apps/details?id=com.sinpo.xnfc"; byte[] data = uri.getBytes(); // about this '3'.. see NdefRecord.createUri which need api level 14 data[0] = 3; NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, null, data); return new NdefMessage(new NdefRecord[] { record }); }
Example 3
Source File: NfcManager.java From NFCard with GNU General Public License v3.0 | 3 votes |
NdefMessage createNdefMessage() { String uri = "3play.google.com/store/apps/details?id=com.sinpo.xnfc"; byte[] data = uri.getBytes(); // about this '3'.. see NdefRecord.createUri which need api level 14 data[0] = 3; NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, null, data); return new NdefMessage(new NdefRecord[] { record }); }