Example usage for android.content Context BLUETOOTH_SERVICE

List of usage examples for android.content Context BLUETOOTH_SERVICE

Introduction

In this page you can find the example usage for android.content Context BLUETOOTH_SERVICE.

Prototype

String BLUETOOTH_SERVICE

To view the source code for android.content Context BLUETOOTH_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.bluetooth.BluetoothManager for using Bluetooth.

Usage

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuService.java

/**
 * Initializes bluetooth adapter//from ww  w.  ja v  a2  s  .  c om
 * 
 * @return <code>true</code> if initialization was successful
 */
private boolean initialize() {
    // For API level 18 and above, get a reference to BluetoothAdapter through
    // BluetoothManager.
    final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    if (bluetoothManager == null) {
        loge("Unable to initialize BluetoothManager.");
        return false;
    }

    mBluetoothAdapter = bluetoothManager.getAdapter();
    if (mBluetoothAdapter == null) {
        loge("Unable to obtain a BluetoothAdapter.");
        return false;
    }

    return true;
}