When i try to use ScanFilter in BleScan in lollipop its not scanning devices(Only when i pass List of ScanFilter). If i pass only one UUID its working fine. But in the case of Multiple its not working..
ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_BALANCED).build();
if (getBluetoothStatus()) {
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
List<ScanFilter> mList=scanFilters(serviceUUIDs);
mBluetoothLeScanner.startScan(mList, settings, mScanCallback);
}
private List<ScanFilter> scanFilters(UUID[] serviceUUIDs) {
List<ScanFilter> list = new ArrayList<>();
for (int i = 0; i <serviceUUIDs.length; i++) {
ScanFilter filter = new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(serviceUUIDs[0].toString())).build();
list.add(filter);
}
return list;
}
that's beacause you don't use the variable to go trough on elements.
try this:
ScanFilter filter = new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(serviceUUIDs[i].toString())).build();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With