本文整理匯總了Java中android.nfc.NdefRecord.RTD_URI屬性的典型用法代碼示例。如果您正苦於以下問題:Java NdefRecord.RTD_URI屬性的具體用法?Java NdefRecord.RTD_URI怎麽用?Java NdefRecord.RTD_URI使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.nfc.NdefRecord
的用法示例。
在下文中一共展示了NdefRecord.RTD_URI屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createUriRecord
/**
* 將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;
}
示例2: onNewIntent
@Override
public void onNewIntent(Intent intent)
{
Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uriField = urlAddress.getBytes(Charset.forName("US-ASCII"));
byte[] payload = new byte[uriField.length + 1]; //add 1 for the URI Prefix
payload[0] = 0x05; //prefixes tel: to the URI
System.arraycopy(uriField, 0, payload, 1, uriField.length); //appends URI to payload
NdefRecord URIRecord = new NdefRecord(
NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
NdefMessage newMessage= new NdefMessage(new NdefRecord[] { URIRecord });
writeNdefMessageToTag(newMessage, tag);
}
示例3: onNewIntent
@Override
public void onNewIntent(Intent intent) {
Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uriField = urlAddress.getBytes(Charset.forName("US-ASCII"));
byte[] payload = new byte[uriField.length + 1]; //add 1 for the URI Prefix
payload[0] = 0x0;
System.arraycopy(uriField, 0, payload, 1, uriField.length); //appends URI to payload
NdefRecord URIRecord = new NdefRecord(
NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
NdefMessage newMessage= new NdefMessage(new NdefRecord[] { URIRecord });
writeNdefMessageToTag(newMessage, tag);
}
示例4: onNewIntent
@Override
public void onNewIntent(Intent intent)
{
Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uriField = urlAddress.getBytes(Charset.forName("US-ASCII"));
byte[] payload = new byte[uriField.length + 1]; //add 1 for the URI Prefix
payload[0] = 0x01;
System.arraycopy(uriField, 0, payload, 1, uriField.length); //appends URI to payload
NdefRecord URIRecord = new NdefRecord(
NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
NdefMessage newMessage= new NdefMessage(new NdefRecord[] { URIRecord });
writeNdefMessageToTag(newMessage, tag);
}
示例5: onNewIntent
@Override
public void onNewIntent(Intent intent)
{
Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uriField = urlAddress.getBytes(Charset.forName("US-ASCII"));
byte[] payload = new byte[uriField.length + 1]; //add 1 for the URI Prefix
payload[0] = 0x06; //prefixes http://www. to the URI
System.arraycopy(uriField, 0, payload, 1, uriField.length); //appends URI to payload
NdefRecord URIRecord = new NdefRecord(
NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
NdefMessage newMessage= new NdefMessage(new NdefRecord[] { URIRecord });
writeNdefMessageToTag(newMessage, tag);
}
示例6: wellKnownUriRecord
private static NdefRecord wellKnownUriRecord(@Nonnull final String uri)
{
final byte[] uriBytes = uri.getBytes(Constants.UTF_8);
final byte[] recordBytes = new byte[uriBytes.length + 1];
recordBytes[0] = (byte) 0x0; // prefix, alway 0 for bitcoin scheme
System.arraycopy(uriBytes, 0, recordBytes, 1, uriBytes.length);
return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], recordBytes);
}
示例7: absoluteUriRecord
private static NdefRecord absoluteUriRecord(@Nonnull final String uri)
{
return new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, NdefRecord.RTD_URI, new byte[0], uri.getBytes(Constants.UTF_8));
}
示例8: getType
@Override
public String getType() {
return new String(NdefRecord.RTD_URI);
}
示例9: createNdefMessage
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 });
}