当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothLeAdvertiser类代码示例

本文整理汇总了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;
}
 
开发者ID:adriancretu,项目名称:beacons-android,代码行数:21,代码来源:Advertiser.java

示例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!");
    }
}
 
开发者ID:AsteroidOS,项目名称:AsteroidOSSync,代码行数:14,代码来源:P_AndroidBluetoothManager.java

示例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!");
    }
}
 
开发者ID:AsteroidOS,项目名称:AsteroidOSSync,代码行数:14,代码来源:P_AndroidBluetoothManager.java

示例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;
}
 
开发者ID:adriancretu,项目名称:beacons-android,代码行数:16,代码来源:Advertiser.java

示例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);
}
 
开发者ID:swandroid,项目名称:swan-sense-studio,代码行数:14,代码来源:BLEManager.java

示例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;
}
 
开发者ID:iDevicesInc,项目名称:SweetBlue,代码行数:11,代码来源:L_Util.java

示例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);
        }
    }
}
 
开发者ID:iDevicesInc,项目名称:SweetBlue,代码行数:12,代码来源:L_Util.java

示例8: getAdvertiser

import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private BluetoothLeAdvertiser getAdvertiser(BluetoothAdapter adapter) {
    return adapter.getBluetoothLeAdvertiser();
}
 
开发者ID:RayTW,项目名称:BLEServerSimple,代码行数:5,代码来源:AdvertiseAdaptor.java

示例9: getBluetoothLeAdvertiser

import android.bluetooth.le.BluetoothLeAdvertiser; //导入依赖的package包/类
public static BluetoothLeAdvertiser getBluetoothLeAdvertiser(BluetoothAdapter adapter)
{
    return adapter.getBluetoothLeAdvertiser();
}
 
开发者ID:AsteroidOS,项目名称:AsteroidOSSync,代码行数:5,代码来源:L_Util.java


注:本文中的android.bluetooth.le.BluetoothLeAdvertiser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。