本文整理匯總了Java中android.nfc.NdefRecord.toUri方法的典型用法代碼示例。如果您正苦於以下問題:Java NdefRecord.toUri方法的具體用法?Java NdefRecord.toUri怎麽用?Java NdefRecord.toUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.nfc.NdefRecord
的用法示例。
在下文中一共展示了NdefRecord.toUri方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseNfcUri
import android.nfc.NdefRecord; //導入方法依賴的package包/類
private boolean parseNfcUri(NdefRecord record) {
Uri uri = record.toUri();
if (uri == null) {
return false;
}
if (uri.getHost().equals("v1.0.0")) {
this.mVendor = "com.google";
this.mModel = "cardboard";
this.mVersion = "1.0";
return true;
}
List<String> segments = uri.getPathSegments();
if (segments.size() != 2) {
return false;
}
this.mVendor = uri.getHost();
this.mModel = ((String) segments.get(0));
this.mVersion = ((String) segments.get(1));
return true;
}
示例2: parseNdefRecord
import android.nfc.NdefRecord; //導入方法依賴的package包/類
@SuppressLint("NewApi")
public static UriRecord parseNdefRecord(NdefRecord ndefRecord) {
if (android.os.Build.VERSION.SDK_INT >= 16) {
return new UriRecord(ndefRecord.toUri());
} else {
byte[] payload = ndefRecord.getPayload();
if (payload.length < 2) {
return null;
}
// payload[0] contains the URI Identifier Code, as per
// NFC Forum "URI Record Type Definition" section 3.2.2.
int prefixIndex = (payload[0] & (byte)0xFF);
if (prefixIndex < 0 || prefixIndex >= URI_PREFIX_MAP.length) {
return null;
}
String prefix = URI_PREFIX_MAP[prefixIndex];
String suffix = new String(Arrays.copyOfRange(payload, 1, payload.length),
Charset.forName("UTF-8"));
return new UriRecord(Uri.parse(prefix + suffix));
}
}
示例3: getInviteJellyBean
import android.nfc.NdefRecord; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Invite getInviteJellyBean(NdefRecord record) {
return new Invite(record.toUri());
}
示例4: getInviteJellyBean
import android.nfc.NdefRecord; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Invite getInviteJellyBean(NdefRecord record) {
return new Invite(record.toUri());
}
示例5: getJellyBean
import android.nfc.NdefRecord; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Uri getJellyBean(NdefRecord record) {
return record.toUri();
}