Android打开蓝牙的两种方式
隐式打开方式 关键API使用如下: if ( !bluetoothAdapter.isEnabled()) { boolean res = bluetoothAdapter.enable(); } 完整判断逻辑如下: bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter == null) { Log.e(TAG, "--------------- 不支持蓝牙"); return; } if ( !bluetoothAdapter.isEnabled()) { boolean res = bluetoothAdapter.enable(); if (res == true) { myBtResultCallback.showToastMsg("蓝牙打开成功"); } else { myBtResultCallback.showToastMsg("蓝牙打开失败"); } } else if (bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { myBtResultCallback.showToastMsg("蓝牙已打开"); } else { myBtResultCallback.showToastMsg(