List of usage examples for android.bluetooth BluetoothAdapter disable
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) public boolean disable()
From source file:Main.java
public static void closeBt() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mBluetoothAdapter.disable(); }
From source file:Main.java
public static void offBluetooth() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter.isEnabled()) { bluetoothAdapter.disable(); }//from w w w . java2 s. 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 va2 s .c o m }
From source file:Main.java
public static void disableBluetooth() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { bluetoothAdapter.disable(); }//from w ww .j av a 2s. c om }
From source file:Main.java
public static boolean operation(boolean isOpen) { BluetoothAdapter blueAdapter = BluetoothAdapter.getDefaultAdapter(); if (isOpen) { return blueAdapter.enable(); } else {// w w w . ja va 2 s . c o m return blueAdapter.disable(); } }
From source file:Main.java
public static void stopBluetooth() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter != null) { if (bluetoothAdapter.isEnabled()) { bluetoothAdapter.disable(); }//from ww w . ja v a 2s. co m } }
From source file:Main.java
public static boolean enableBluetooth(boolean bEnable) { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { // Bluetooth not supported return false; }//from w w w .j a v a 2s .com return bEnable ? btAdapter.enable() : btAdapter.disable(); }
From source file:Main.java
private static void setBluetooth(int btVal) { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (btVal == 0 && !bluetoothAdapter.isEnabled()) { bluetoothAdapter.enable();// w w w . ja va 2 s . c o m } else if (btVal == 1 && bluetoothAdapter.isEnabled()) { bluetoothAdapter.disable(); } }
From source file:Main.java
public static boolean setBluetooth(boolean enable) { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); boolean isEnabled = bluetoothAdapter.isEnabled(); if (enable && !isEnabled) { return bluetoothAdapter.enable(); } else if (!enable && isEnabled) { return bluetoothAdapter.disable(); }//from w ww .ja v a2 s .c o m // No need to change bluetooth state return true; }
From source file:Main.java
public static void toggleBlueTooth(Context context) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { switch (adapter.getState()) { case BluetoothAdapter.STATE_OFF: adapter.enable();/*from w w w .jav a 2 s. c o m*/ break; case BluetoothAdapter.STATE_ON: adapter.disable(); break; } } }