Example usage for android.bluetooth.le ScanSettings SCAN_MODE_LOW_POWER

List of usage examples for android.bluetooth.le ScanSettings SCAN_MODE_LOW_POWER

Introduction

In this page you can find the example usage for android.bluetooth.le ScanSettings SCAN_MODE_LOW_POWER.

Prototype

int SCAN_MODE_LOW_POWER

To view the source code for android.bluetooth.le ScanSettings SCAN_MODE_LOW_POWER.

Click Source Link

Document

Perform Bluetooth LE scan in low power mode.

Usage

From source file:com.android.bleserver.ScannerFragment.java

/**
 * Return a {@link ScanSettings} object set to use low power (to preserve battery life).
 *///from ww w. j  av  a2 s.c om
private ScanSettings buildScanSettings() {
    ScanSettings.Builder builder = new ScanSettings.Builder();
    builder.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER);
    return builder.build();
}

From source file:net.jpuderer.android.bluedoor.DoorlockService.java

private void startBluetoothLeScan() {
    Log.d(TAG, "startBluetoothLeScan");
    // Stop any existing scan first
    mBluetoothLeScanner.stopScan(mScanCallback);
    // Start low power BT-LE scanning
    final ScanFilter scanFilter = new ScanFilter.Builder().setDeviceAddress(getDefaultDeviceAddress()).build();
    final ScanSettings scanSettings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
            .build();//from   w w  w . j a va  2s.  c  o  m
    mBluetoothLeScanner.startScan(Arrays.asList(scanFilter), scanSettings, mScanCallback);
}