本文整理汇总了Java中android.bluetooth.le.AdvertiseSettings.ADVERTISE_MODE_BALANCED属性的典型用法代码示例。如果您正苦于以下问题:Java AdvertiseSettings.ADVERTISE_MODE_BALANCED属性的具体用法?Java AdvertiseSettings.ADVERTISE_MODE_BALANCED怎么用?Java AdvertiseSettings.ADVERTISE_MODE_BALANCED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.bluetooth.le.AdvertiseSettings
的用法示例。
在下文中一共展示了AdvertiseSettings.ADVERTISE_MODE_BALANCED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAdvertiseInterval
@SuppressLint("InlinedApi")
@Override
public int setAdvertiseInterval(int advertiseIntervalMs) {
Util.log(TAG, "setAdvertiseInterval() called with: advertiseIntervalMs = [" + advertiseIntervalMs + "]");
@Advertiser.Mode int mode;
if (advertiseIntervalMs <= 100 + (250 - 100) / 2) {
// 100 ms
mode = AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY;
} else if (advertiseIntervalMs >= 1000 - (1000 - 250) / 2) {
// 1000 ms
mode = AdvertiseSettings.ADVERTISE_MODE_LOW_POWER;
} else {
// 250 ms actually
mode = AdvertiseSettings.ADVERTISE_MODE_BALANCED;
}
if (mode != getModifiedOrOriginalBeacon().getAdvertiseMode()) {
// restarting a beacon destroys the GATT connection, make sure we use a stopped clone
getOrCloneConfiguredBeacon().edit().setAdvertiseMode(mode).apply();
}
return getAdvertiseInterval();
}
示例2: getAdvertiseInterval
@Override
public int getAdvertiseInterval() {
switch (getModifiedOrOriginalBeacon().getAdvertiseMode()) {
case AdvertiseSettings.ADVERTISE_MODE_LOW_POWER:
default:
return 1000;
case AdvertiseSettings.ADVERTISE_MODE_BALANCED:
return 250;
case AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY:
return 100;
}
}
示例3: createBeacon
/**
* Creates an UriioBeacon beacon based on the provided URL registration result.
* @param urlResource URL registration info
* @param beaconTimeToLive Initial value for the beacon's TTL for issuing ephemeral short URLs.
* @return A new beaoon, without saving or starting it. You can adjust any other beacon properties and save it.
*/
@NonNull
public static UriioBeacon createBeacon(UrlResource urlResource, int beaconTimeToLive) {
return new UriioBeacon(urlResource.getId(), urlResource.getToken(),
beaconTimeToLive, urlResource.getUrl(),
AdvertiseSettings.ADVERTISE_MODE_BALANCED,
AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM);
}