Bluetooth Low Energy Bluetooth Problems with Scanning Filter

When I try to use ScanFilter in BleScan on lollipop its not scanning devices (only when I pass List of ScanFilter). If I only pass one UUID it works fine. But in case of Multiple it doesn't work.

 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();


          return list;



source to share

1 answer

because you are not using a variable to go through the elements.

try this:

ScanFilter filter = new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(serviceUUIDs[i].toStri‌​ng())).build(); 




All Articles