如何在Android设备上通过MAC地址断开蓝牙连接?

时间:2018-08-18 00:34:59

标签: android bluetooth

我使用了以下代码,尽管调试时所有步骤都消失了,但是我无法断开蓝牙连接。

/**
 * Disconnect
 *
 * @param address Mac Address
 */
public void disConnectDevice(String address) {
    BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
    BluetoothGatt mBluetoothGatt = device.connectGatt(this, false, gattCallback);
    mBluetoothGatt.disconnect();
}

private BluetoothGattCallback gattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
        super.onConnectionStateChange(gatt, status, newState);
        gatt.close();
    }
};

1 个答案:

答案 0 :(得分:0)

SELECT distinct
DATEADD(DD,7-CHOOSE(DATEPART(dw, PostDate), 2,3,4,5,6,7,1),PostDate) AS WeekEndDate
from [TransactionMasterReport]
where PostDate between '12/30/2017' and '07/1/2018'
order by WeekEndDate