我正在实施蓝牙低功耗扫描应用程序。我设置了一个空的扫描过滤器,以避免屏幕锁定时8.1+的扫描限制。
ScanFilter filter = new ScanFilter.Builder().build();
ScanSettings.Builder builder = new ScanSettings.Builder();
//CONSTANT FOR LOW BATTERY MODE
builder.setScanMode(0x00000000);
final ScanSettings ss = builder.build();
final List<ScanFilter> filters = new ArrayList<>();
filters.add(filter);
AsyncTask.execute(() -> {
if (btScanner != null && btAdapter != null && btAdapter.isEnabled()) {
System.out.println("STARTED SCANNING");
btScanner.startScan(filters, ss, leScanCallback);
scanning = true;
}
});
在三星以外的设备上扫描时,此方法有效。屏幕锁定在三星设备上时,是否有人能够扫描BLE设备?我也尝试过MAC地址过滤,但这似乎也不起作用。