Code example for BluetoothAdapter

Methods: disable, enable, getState

0
    private void toggleBluetooth() { 
        if (mBluetoothAdapter == null) {
            mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        } 
 
        int state = mBluetoothAdapter.getState();
 
        if (state == BluetoothAdapter.STATE_TURNING_OFF
                || state == BluetoothAdapter.STATE_TURNING_ON) {
            return; 
        } 
        if (state == BluetoothAdapter.STATE_OFF) {
            mBluetoothAdapter.enable();
            notifyKey(ASUSDEC_BT, ASUSDEC_STATUS_ON);
        } 
        if (state == BluetoothAdapter.STATE_ON) {
            mBluetoothAdapter.disable();
            notifyKey(ASUSDEC_BT, ASUSDEC_STATUS_OFF);
        } 
    } 
 
    private void toggleTouchpad() {