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?

Dmitrii Sidenko
  • 660
  • 6
  • 19
Sanjay Kakadiya
  • 1,596
  • 1
  • 15
  • 32
  • Is it the scanning or the connecting that doesn't work? Any error/status codes? Logcat messages? – Emil Oct 09 '19 at 08:09
  • The connection doesn't work. I am not to get logcat because of this happen on customer's devices. – Sanjay Kakadiya Oct 09 '19 at 08:32
  • 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. – M Tomczynski Oct 22 '19 at 08:33
  • Are you using bonding? Is the device broadcasting publicly or privately? – M Tomczynski Nov 20 '19 at 10:30
  • @MTomczyński I didn't use bonding and the device is broadcasting publicly. – Sanjay Kakadiya Nov 21 '19 at 10:10
  • @SanjayKakadiya are you scanning before connection attempt or are you just trying to connect to mac address that you stored somewhere? – M Tomczynski Nov 21 '19 at 11:03
  • @MTomczyński I'm scanning before connection. If the device found in a scan then I'll try to connect. – Sanjay Kakadiya Nov 23 '19 at 13:52
  • @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 it – M Tomczynski Nov 24 '19 at 12:23
  • 3
    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. – Brian Reinhold Nov 25 '19 at 21:48
  • Is there any solution or work around yet? – Omer Feb 11 '20 at 16:35
  • 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_LOCATION` – Muhammed Aydogan Jun 15 '20 at 14:20
  • 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. – Arun Badole Jul 28 '20 at 07:25
  • See the following as this question may be a potential duplicate: [Android 10 not working with BLE Bluetooth scanning](https://stackoverflow.com/questions/58428763/android-10-not-working-with-ble-bluetooth-scanning/64799686#64799686) – st920228 Nov 12 '20 at 07:41

1 Answers1

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

Zachary Moshansky
  • 1,673
  • 18
  • 32