startLeScan with 128 bit UUIDs doesn't work on native Android BLE implementation
This is a reported bug at least in Android 4.3 JWR66Y:
- Filtering works, if I provide my 16bit UUID
- Filtering doesn't return any scan results, if I provide my 128bit UUID or if I provide both UUIDs
My setting: My device offers 2 UUIDs on advertising (1 16bit and 1 128bit) and 4 UUIDs on service discovery (1 128bit and 3 16bit).
Even if it gets fixed, I warn everybody against using the filter option provided by Android. For backward compatibility and since it's broken on Samsung Galaxy S3 with Android 4.3
Android Bluetooth device UUID
You may search for devices only for your specified UUID: (Android BLE Doc)
public boolean startLeScan (UUID[] serviceUuids, BluetoothAdapter.LeScanCallback callback)
But, there are known issues in Android version 4.4.4 with this method, may it change in the future.
You may use this method successfully with 16 bit UUID search, but it would fail with 128 bit UUID on Nexus devices. (Worked on Samsung S5 for me).
If you want to stick with 128 bit UUID search, you need some workaround (at least for current android version 4.4.4)
This post has some good details about scanRecord byte array structure.
Android BLE. device.getUUids() always return null
There are two ways for a central application to know service UUIDs supported by a beacon.
One way is to extract information from advertisement packets that beacons emit. But if beacons do not emit such packets (e.g. packets whose AD type is 0x03), a central application cannot get information about service UUIDs by this way.
The other way is to connect a target beacon and explicitly require information about service UUIDs supported by the beacon.
JavaDoc of getUuids() method says as follows:
This method does not start a service discovery procedure to retrieve the UUIDs from the remote device. Instead, the local cached copy of the service UUIDs are returned.
So, (1) if a beacon does not emit packets which include information about service UUIDs and (2) if you have not required the beacon to return information about service UUIDs (e.g. if you have not performed 'service discovery'), getUuids() returns null.
Related Topics
Programmatically Add View One Below Other in Relative Layout
Pagination Not Work for the Recyclerview Within Nestedscrollview
Continuous Speech Recognition Android
How to Set Alarm in Android Programmatically
Suppress/Block Broadcastreceiver in Another App
Android: Fragments Overlapping Issue
Downloading/Caching Google Maps for Offline Use
Which Can Replace Capturepicture Function
Alertdialog.Getbutton() Method Gives Null Pointer Exception Android
How to Send Data Message Using Firebase Console
How Does Native Android Code Written for Arm Run on X86
Exporting SQLite Database to CSV File in Android
Android Webview Click Open Within Webview Not a Default Browser
Android - Running a Method Periodically Using Postdelayed() Call
How to Check If "Android.Permission.Package_Usage_Stats" Permission Is Given