5
votes

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.

2
I'm pretty sure I faced this even before Android10ror
Maybe you're testing with location turned on and were not aware i guess. I work with ble app and that happens on others version than 10 as well. Check out this topic: stackoverflow.com/questions/33045581/…Shermano
I'm getting onScanResults with the app in foreground when i run with location turned off BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner().startScan(...); My app is live and we received a complaint from a user with Android 10 and upon testing with my phone i'm having the same issue.GudniPall
@GudniPall were you able to solve. I am also having the same issue. If possible please check stackoverflow.com/questions/65105856/…WISHY
@WISHY Location has to be turned on for devices running Android 10. I added a popup asking the user to enable Location if it's turned off.GudniPall

2 Answers

8
votes

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.

0
votes

on android 10 ask these three permission

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

declare in manifest and also ask at runtime