Android 10 BLE connection issue
Asked Answered
F

1

19

I am working on an app that is connected to the BLE device using BluetoothGatt.

I am successfully able to scan and connect with BLE devices in all devices like Samsung, Pixel, etc. I followed Android official BLE connection guide for scanning and connection.

But after updating my Pixel 2 to Android 10, I am not able to connect my BLE device to Pixel 2. I also, seen the same issue was reported in Google issue tracker.

To fix this I tried clear Bluetooth app cache and Network reset but It works in some devices but not all.

Is there anything that needs to be done to fix this issue or is there a proper way to clear Bluetooth app cache and Network reset programmatically.

Or any other way to manage BLE connection in Android?

Forepleasure answered 9/10, 2019 at 7:56 Comment(13)
Is it the scanning or the connecting that doesn't work? Any error/status codes? Logcat messages?Hautrhin
The connection doesn't work. I am not to get logcat because of this happen on customer's devices.Forepleasure
I have the same problem but it only occurs when two devices from same company are paired, I can't connect to any of them. After unpairing second one connection is fine.Sapp
Are you using bonding? Is the device broadcasting publicly or privately?Sapp
@MTomczyński I didn't use bonding and the device is broadcasting publicly.Forepleasure
@SanjayKakadiya are you scanning before connection attempt or are you just trying to connect to mac address that you stored somewhere?Sapp
@MTomczyński I'm scanning before connection. If the device found in a scan then I'll try to connect.Forepleasure
@SanjayKakadiya some devices have problems with connecting while phone is scanning. It's good to turn off the scan and wait let's say at least 500ms before trying to establish connection. Issue tracker that you're reffering to have problems with reconnecting to bonded devices with private resolvable address not connecting to publicly advertising device. If nothing helps, please attach HCI logs so we could have more info to investigate further. There're major changes under the hood on how Android 10 connects to BLE devices. Unfortunetly there's nothing in official documentation about itSapp
I have the same problem. I am using the BleScanner and it is not detecting advertisements. If I build the app using 28 it DOES work even on Android 10, but if I build using 29 it does NOT work. Exact same code.Radborne
Is there any solution or work around yet?Doublethink
In my case, my ble app works fine in api 29 or some other lower apis in whole bunch of phones but after I upgraded my phone (Redmi note 8 pro) to api 30, it started to not working. Even though I also gave permission android.permission.ACCESS_BACKGROUND_LOCATIONDonnettedonni
I am facing same issue in my app. On Android Q devices and few Samsung phones, app is getting disconnected automatically. Please let me know if anyone has solved this problem.Lem
See the following as this question may be a potential duplicate: Android 10 not working with BLE Bluetooth scanningMightily
S
2

On Android 10 (API 29), permissions changed and now require ACCESS_FINE_LOCATION for BLE scanning if it is your compilation target.

However, if you've compiled against API 28, and have ACCESS_COARSE_LOCATION, it should continue to work on Android 10.

Src: https://developer.android.com/about/versions/10/privacy/changes#location-telephony-bluetooth-wifi

See the following as this question may be a potential duplicate: Android 10 not working with BLE Bluetooth scanning

Sample answered 18/6, 2020 at 18:38 Comment(2)
Without ACCESS_FINE_LOCATION we cannot do BLE scanning?Savonarola
@IgorGanapolsky, yes, we cannot. Check the docs for more: developer.android.com/guide/topics/connectivity/…Zinciferous

© 2022 - 2024 — McMap. All rights reserved.