我正在使用MI Note 4(Android 7.0)和Moto X Play(Android 7.1.1)。我正在一个单独的服务中进行BLE扫描。在扫描时,我得到了“扫描失败”的扫描响应。打开/关闭蓝牙不影响扫描响应。打开/关闭Wifi也不影响扫描响应。(但是,在这种情况下,Android内置(从设置->蓝牙)蓝牙扫描可以正常工作。)我还使用了BLE扫描应用程序,但该应用程序也无法检测到BLE广告!我尝试了打开/关闭飞行模式,我的设备能够成功扫描。扫描功能:
mLeScanner.startScan(filters, scanSettings, mScanCallback);
扫描回调:
ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
Log.e("TAG","onScanResult");
}
@Override
public void onScanFailed(int errorCode) {
super.onScanFailed(errorCode);
Log.e("TAG","onScanFailed");
}
}
扫描设置:
scanSettings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
筛选器:
List<ScanFilter> filters = new ArrayList<>();
ScanFilter filter = new ScanFilter.Builder().setDeviceAddress("device address").build();
filters.add(filter);
信标扫描过滤器
ScanFilter.Builder builder = new ScanFilter.Builder();
builder.setManufacturerData(0x004c, new byte[]{});
有人知道为什么只有切换飞行模式才能使其工作吗?
网络会影响BLE扫描吗?