本文整理匯總了Java中android.os.ParcelUuid.fromString方法的典型用法代碼示例。如果您正苦於以下問題:Java ParcelUuid.fromString方法的具體用法?Java ParcelUuid.fromString怎麽用?Java ParcelUuid.fromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.ParcelUuid
的用法示例。
在下文中一共展示了ParcelUuid.fromString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jsonToBleAdvertiseData
import android.os.ParcelUuid; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static AdvertiseData jsonToBleAdvertiseData(JSONObject jsonObject) throws JSONException {
AdvertiseData.Builder builder = new AdvertiseData.Builder();
if (jsonObject.has("IncludeDeviceName")) {
builder.setIncludeDeviceName(jsonObject.getBoolean("IncludeDeviceName"));
}
if (jsonObject.has("IncludeTxPowerLevel")) {
builder.setIncludeTxPowerLevel(jsonObject.getBoolean("IncludeTxPowerLevel"));
}
if (jsonObject.has("ServiceData")) {
JSONArray serviceData = jsonObject.getJSONArray("ServiceData");
for (int i = 0; i < serviceData.length(); i++) {
JSONObject dataSet = serviceData.getJSONObject(i);
ParcelUuid parcelUuid = ParcelUuid.fromString(dataSet.getString("UUID"));
builder.addServiceUuid(parcelUuid);
if (dataSet.has("Data")) {
byte[] data = Base64.decode(dataSet.getString("Data"), Base64.DEFAULT);
builder.addServiceData(parcelUuid, data);
}
}
}
if (jsonObject.has("ManufacturerData")) {
JSONObject manufacturerData = jsonObject.getJSONObject("ManufacturerData");
int manufacturerId = manufacturerData.getInt("ManufacturerId");
byte[] manufacturerSpecificData =
Base64.decode(jsonObject.getString("ManufacturerSpecificData"), Base64.DEFAULT);
builder.addManufacturerData(manufacturerId, manufacturerSpecificData);
}
return builder.build();
}
示例2: pbgattAdvertiseStart
import android.os.ParcelUuid; //導入方法依賴的package包/類
public void pbgattAdvertiseStart(byte[] serviceData) {
if(D){
Log.d(TAG, "pbgattAdvertiseStart");
}
ParcelUuid uu = ParcelUuid.fromString(UUID_PB_SVC);
mBluetoothLeAdvertiser.startAdvertising(createAdvSettings(true,0),
createAdvertiseData(uu, serviceData),
mAdvertiseCallback);
}
示例3: parcelFromShortValue
import android.os.ParcelUuid; //導入方法依賴的package包/類
/**
* Obtains a ParcelUuid from Short style value.
*
* @param uuidShortValue the Short style UUID value.
* @return an UUID instance.
*/
@NonNull
public static ParcelUuid parcelFromShortValue(final int uuidShortValue) {
return ParcelUuid.fromString(UUID_LONG_STYLE_PREFIX + String.format("%04X", uuidShortValue & 0xffff) + UUID_LONG_STYLE_POSTFIX);
}