Commit ba851b6271beb897cc228cc350993c35f283e27a
1 parent
034e8d08
1 修复搜索设备页空指针问题
Showing
2 changed files
with
8 additions
and
6 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/SearchDevicefragment.java
| ... | ... | @@ -89,15 +89,17 @@ public class SearchDevicefragment extends MvpBindingFragment<SearchDevicefragmen |
| 89 | 89 | * 初始化蓝牙扫描 |
| 90 | 90 | */ |
| 91 | 91 | private void initBlueToothScanConfig() { |
| 92 | - BleManager.getInstance().init(getActivity().getApplication()); | |
| 93 | - BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder() | |
| 92 | + if (null != getActivity().getApplication()) { | |
| 93 | + BleManager.getInstance().init(getActivity().getApplication()); | |
| 94 | + BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder() | |
| 94 | 95 | // .setServiceUuids(serviceUuids) // 只扫描指定的服务的设备,可选 |
| 95 | 96 | // .setDeviceName(true, names) // 只扫描指定广播名的设备,可选 |
| 96 | 97 | // .setDeviceMac(mac) // 只扫描指定mac的设备,可选 |
| 97 | 98 | // .setAutoConnect(isAutoConnect) // 连接时的autoConnect参数,可选,默认false |
| 98 | - .setScanTimeOut(1000 * 60) // 扫描超时时间,可选,默认10秒;小于等于0表示不限制扫描时间 | |
| 99 | - .build(); | |
| 100 | - BleManager.getInstance().initScanRule(scanRuleConfig); | |
| 99 | + .setScanTimeOut(1000 * 60) // 扫描超时时间,可选,默认10秒;小于等于0表示不限制扫描时间 | |
| 100 | + .build(); | |
| 101 | + BleManager.getInstance().initScanRule(scanRuleConfig); | |
| 102 | + } | |
| 101 | 103 | } |
| 102 | 104 | |
| 103 | 105 | @Override | ... | ... |