當前位置: 首頁>>代碼示例>>Java>>正文


Java NdefRecord.RTD_URI屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:jopenbox,項目名稱:android-nfc,代碼行數:24,代碼來源:WriteUriActivity.java

示例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);     
}
 
開發者ID:ShravanJ,項目名稱:easyNFC-dev,代碼行數:15,代碼來源:Writephoneactivity.java

示例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);     
}
 
開發者ID:ShravanJ,項目名稱:easyNFC-dev,代碼行數:13,代碼來源:WriteApp.java

示例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);     
}
 
開發者ID:ShravanJ,項目名稱:easyNFC-dev,代碼行數:15,代碼來源:WriteUrlActivity.java

示例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);     
}
 
開發者ID:ShravanJ,項目名稱:easyNFC-dev,代碼行數:15,代碼來源:WriteMailActivity.java

示例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);
}
 
開發者ID:9cat,項目名稱:templecoin-android-wallet,代碼行數:8,代碼來源:Nfc.java

示例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));
}
 
開發者ID:9cat,項目名稱:templecoin-android-wallet,代碼行數:4,代碼來源:Nfc.java

示例8: getType

@Override
public String getType() {
	return new String(NdefRecord.RTD_URI);
}
 
開發者ID:andresteves,項目名稱:NFC-Reader-and-Chat,代碼行數:4,代碼來源:UriRecord.java

示例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 });
	}
 
開發者ID:sinpolib,項目名稱:nfcard,代碼行數:13,代碼來源:NfcManager.java


注:本文中的android.nfc.NdefRecord.RTD_URI屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。