Example usage for android.bluetooth BluetoothAdapter isEnabled

List of usage examples for android.bluetooth BluetoothAdapter isEnabled

Introduction

In this page you can find the example usage for android.bluetooth BluetoothAdapter isEnabled.

Prototype

@RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isEnabled() 

Source Link

Document

Return true if Bluetooth is currently enabled and ready for use.

Usage

From source file:Main.java

public static boolean isBluetoothEnabled(BluetoothAdapter adapter) {
    return adapter != null && adapter.isEnabled();
}

From source file:Main.java

public static boolean getBluetoothIsOpen() {
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    return adapter.isEnabled();
}

From source file:Main.java

public static boolean isOpen(BluetoothAdapter adapter) {
    if (null != adapter) {
        return adapter.isEnabled();
    }//from w w  w  . j a va 2 s  .  co m
    return false;
}

From source file:Main.java

/**
 * Ensure Bluetooth is turned on.//from   ww w  .j  a  v a 2 s.c o  m
 *
 * @throws IllegalStateException If {@code adapter} is null or Bluetooth state is not
 *             {@link BluetoothAdapter#STATE_ON}.
 */
static void checkAdapterStateOn(BluetoothAdapter adapter) {
    if (adapter == null || !adapter.isEnabled()) {//adapter.getState() != BluetoothAdapter.STATE_ON) {
        throw new IllegalStateException("BT Adapter is not turned ON");
    }
}

From source file:Main.java

public static void offBluetooth() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter.isEnabled()) {
        bluetoothAdapter.disable();/*from   ww w. java2s .c om*/
    }
}

From source file:Main.java

public static void stopBluetooth() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter.isEnabled()) {
        bluetoothAdapter.disable();//from   w  w  w .  j a  v  a2 s .  co m
    }
}

From source file:Main.java

public static boolean isOpenBt() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    return mBluetoothAdapter.isEnabled();
}

From source file:Main.java

public static void startBluetooth() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (!bluetoothAdapter.isEnabled()) {
        bluetoothAdapter.enable();//  ww w  . j av  a 2s .  co m
    }
}

From source file:Main.java

public static void onBluetooth() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (!bluetoothAdapter.isEnabled()) {
        bluetoothAdapter.enable();//from   w  w w. j a va2s  .  co  m
        Log.i("Log", "Bluetooth is Enabled");
    }
}

From source file:Main.java

/**
 * Determine if bluetooth is turned on.// w w  w .j av a 2 s.  c om
 *
 * @return True if bloetuuth is turned on.
 */
public static boolean isBluetoothOn() {
    final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    return bluetoothAdapter.isEnabled();
}