After upgrading my Pixel XL to Android version 10.0 Bluetooth Low Energy (BLE) scanning will only work if i have Location turned on.
This has not been an issue until now and it's working on multiple devices running on Android 9.0, 8.0 and 6.0.1.
My app is only scanning in foreground using BluetoothLeScanner
startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
My app has FINE_LOCATION, COARSE_LOCATION and BLUETOOTH permissions, I've tried adding ACCESS_BACKGROUND_LOCATION permission but had no luck.
Are there stricter requirements in Android 10.0 for apps to scan for Bluetooth devices, i can't find anything about this and am hoping i don't have to ask users to turn on Location for my app to work.
Caution: BLE scanning typically needs location permissions as BLE scanning identifies objects that could be used for geolocation. Turning off location services will turn off Bluetooth scanning. From Android 12, apps that declare neverForLocation can gain Bluetooth scanning results even when location services are off.
1- If you want to search nearby Bluetooth devices, you must add BLUETOOTH_SCAN permission. 2- If you want your device to be discovered by other devices, you must add BLUETOOTH_ADVERTISE permission. 3- If you want your device to be communicable with other devices, you must add BLUETOOTH_CONNECT permission.
Target Android 12 or higher The CDM system provides a pairing UI on behalf of your app and doesn't require location permissions.
As of Android 10, it is now required to have ACCESS_FINE_LOCATION turned on in order to perform Bluetooth operations. The reason for this is that Bluetooth can be used to gather information about the location of the user (e.g. using BLE beacons), and for that the relevant app permission should be declared.
For Android 9 and lower, ACCESS_COARSE_LOCATION is sufficient which is probably why your app was working without an issue.
More information can be found here:-
I hope this helps.
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