/** 查看手机蓝牙是否可用,若当前状态为不可用,则默认调用意图请求打开系统蓝牙 */ public boolean checkBLEEnable() throws BleNotAvailableException { try { if (mBeaconManager.checkAvailability()) { // 支持ble 且蓝牙已打开 return true; } else { // 支持ble 但蓝牙未打开 return false; } } catch (BleNotAvailableException e) { // 当设备没有bluetooth或没有ble时,会产生该异常 throw new BleNotAvailableException("Bluetooth LE not supported by this device"); } }