这里会显示出您选择的修订版和当前版本之间的差别。
后一修订版 | 前一修订版 | ||
cc2640r2f:android_ble_development [2017/09/01 12:00] long 创建 |
cc2640r2f:android_ble_development [2021/06/22 23:14] (当前版本) |
||
---|---|---|---|
行 83: | 行 83: | ||
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); | (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); | ||
mBluetoothAdapter = bluetoothManager.getAdapter(); | mBluetoothAdapter = bluetoothManager.getAdapter(); | ||
- | |||
``` | ``` | ||
+ | |||
2. Enable Bluetooth | 2. Enable Bluetooth | ||
Next, you need to ensure that Bluetooth is enabled. Call isEnabled() to check whether Bluetooth is currently enabled. If this method returns false, then Bluetooth is disabled. The following snippet checks whether Bluetooth is enabled. If it isn't, the snippet displays an error prompting the user to go to Settings to enable Bluetooth: | Next, you need to ensure that Bluetooth is enabled. Call isEnabled() to check whether Bluetooth is currently enabled. If this method returns false, then Bluetooth is disabled. The following snippet checks whether Bluetooth is enabled. If it isn't, the snippet displays an error prompting the user to go to Settings to enable Bluetooth: |