这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
cc2640r2f:android_ble_development [2017/09/02 17:38] long ↷ 页面android_ble_development:ble:ble被移动至cc2640r2f:android_ble_development:ble |
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: |