Example usage for android.bluetooth.le AdvertiseSettings ADVERTISE_TX_POWER_MEDIUM

List of usage examples for android.bluetooth.le AdvertiseSettings ADVERTISE_TX_POWER_MEDIUM

Introduction

In this page you can find the example usage for android.bluetooth.le AdvertiseSettings ADVERTISE_TX_POWER_MEDIUM.

Prototype

int ADVERTISE_TX_POWER_MEDIUM

To view the source code for android.bluetooth.le AdvertiseSettings ADVERTISE_TX_POWER_MEDIUM.

Click Source Link

Document

Advertise using medium TX power level.

Usage

From source file:Main.java

@TargetApi(21)
public static AdvertiseSettings getAdvertiseSettings(boolean connectable) {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER);
    builder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM);
    builder.setConnectable(connectable);

    return builder.build();
}

From source file:edu.umich.eecs.lab11.camera.CameraFragment.java

private void startAdvertising() {
    if (mBluetoothLeAdvertiser == null)
        return;//from  w w  w  .ja  v a  2  s  . co m

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED).setConnectable(true).setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM).build();

    AdvertiseData data = new AdvertiseData.Builder().addServiceUuid(new ParcelUuid(DeviceProfile.BEACON_UUID))
            .addServiceData(new ParcelUuid(DeviceProfile.BEACON_UUID), DeviceProfile.URI_AD).build();

    mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}