本文整理汇总了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);
}