本文整理汇总了Java中android.bluetooth.le.BluetoothLeAdvertiser类的典型用法代码示例。如果您正苦于以下问题:Java BluetoothLeAdvertiser类的具体用法?Java BluetoothLeAdvertiser怎么用?Java BluetoothLeAdvertiser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BluetoothLeAdvertiser类属于android.bluetooth.le包,在下文中一共展示了BluetoothLeAdvertiser类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
/**
* Attempt to start BLE advertising.
* @param bleAdvertiser BLE advertiser
* @return True if no exception occurred while trying to start advertising.
*/
boolean start(BluetoothLeAdvertiser bleAdvertiser) {
try {
bleAdvertiser.startAdvertising(getAdvertiseSettings(), getAdvertiseData(),
getAdvertiseScanResponse(), this);
} catch (IllegalStateException e) {
// tried to start advertising after Bluetooth was turned off
// let upper level notice that BT is off instead of reporting an error
if (BuildConfig.DEBUG) {
Log.e(TAG, "start", e);
}
return false;
}
return true;
}
示例2: startAdvertising
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
@Override
public final void startAdvertising(AdvertiseSettings settings, AdvertiseData adData, AdvertiseCallback callback)
{
final BluetoothLeAdvertiser ad = L_Util.getBluetoothLeAdvertiser(m_adaptor);
if (ad != null)
{
ad.startAdvertising(settings, adData, callback);
}
else
{
m_bleManager.getLogger().e("Tried to start advertising, but the BluetoothLeAdvertiser was null!");
}
}
示例3: stopAdvertising
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
@Override
public final void stopAdvertising(AdvertiseCallback callback)
{
final BluetoothLeAdvertiser ad = L_Util.getBluetoothLeAdvertiser(m_adaptor);
if (ad != null)
{
ad.stopAdvertising(callback);
}
else
{
m_bleManager.getLogger().e("Tried to stop advertising, but the BluetoothLeAdvertiser was null!");
}
}
示例4: stop
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
/**
* Mark the advertiser as stopped and attempt to actually stop BLE advertisements.
* @param bleAdvertiser BLE advertiser, or null
* @return True if there was no error while trying to stop the Bluetooth advertiser.
*/
boolean stop(BluetoothLeAdvertiser bleAdvertiser) {
updateEstimatedPDUCount();
mStatus = STATUS_STOPPED;
if (null != bleAdvertiser) {
bleAdvertiser.stopAdvertising(this);
}
return true;
}
示例5: advertise
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
private void advertise() throws ExpressionParseException {
final BluetoothLeAdvertiser bleAdvertiser = btAdapter.getBluetoothLeAdvertiser();
AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder().setIncludeDeviceName(true);
for(Map.Entry<String, String> expressionEntry : registeredExpressions.entrySet()) {
SensorValueExpression svExpression = (SensorValueExpression) ExpressionFactory.parse(expressionEntry.getValue());
String sensorValuePath = svExpression.getEntity() + ":" + svExpression.getValuePath();
UUID serviceUuid = getUuidForSensorValuePath(sensorValuePath);
dataBuilder.addServiceUuid(new ParcelUuid(serviceUuid));
}
bleAdvertiser.startAdvertising(advertiseSettings, dataBuilder.build(), advertisingCallback);
}
示例6: startAdvertising
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
public static boolean startAdvertising(BluetoothAdapter adapter, AdvertiseSettings settings, AdvertiseData adData, AdvertisingCallback callback)
{
final BluetoothLeAdvertiser adv = adapter.getBluetoothLeAdvertiser();
if (adv == null)
return false;
m_userAdvCallback = callback;
adv.startAdvertising(settings, adData, m_nativeAdvertiseCallback);
return true;
}
示例7: stopAdvertising
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
public static void stopAdvertising(BluetoothAdapter adapter)
{
if (adapter != null)
{
final BluetoothLeAdvertiser adv = adapter.getBluetoothLeAdvertiser();
if (adv != null)
{
adv.stopAdvertising(m_nativeAdvertiseCallback);
}
}
}
示例8: getAdvertiser
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private BluetoothLeAdvertiser getAdvertiser(BluetoothAdapter adapter) {
return adapter.getBluetoothLeAdvertiser();
}
示例9: getBluetoothLeAdvertiser
import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
public static BluetoothLeAdvertiser getBluetoothLeAdvertiser(BluetoothAdapter adapter)
{
return adapter.getBluetoothLeAdvertiser();
}