1

I am trying to scan for Bluetooth LE devices in Android with Java. Everything worked fine and I released an update and on fresh installs it does not work. I went through every weird and funcky permission related to BLE on Android inclusive of ACCESS_FINE_LOCATION permissions.

Deeply reviewed the following:

https://developer.android.com/guide/topics/connectivity/bluetooth/permissions

I can’t see what I’m doing wrong:

  • My app works on older versions of Android, with a fresh install, on an S7 with Android 8.0.
  • does not work on Samsung S9 and S10+ running Android 9.0 and 11.0, respectively.
  • Location permissions is enabled. I can see this programmatically and via settings. Picture below Screenshot of Location enabled on non-scanning S9 with Android 9.0

I can reproduce the same issue with this independent code base https://github.com/PunchThrough/ble-starter-android.

I thought I was crazy but the above code base is does the same thing for Android 10 and has all the same permissions my app has. with the same problematic results. I’m guessing this is happening for others.

28sec video of issue:

https://youtu.be/PzSZ0RnuORQ

What am I not seeing? What changed?

UPDATE WITH PERMISSIONS:

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BLUETOOTH"
    android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
    android:maxSdkVersion="30" />
-->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
    android:usesPermissionFlags="neverForLocation" />

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


<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
George
  • 11
  • 2
  • Have you tried other device manufacturers other than Samsung? – Morrison Chang Nov 26 '21 at 03:15
  • Does the Log provide any errors? What is the target SDK of your app? – Michael Kotzjan Nov 26 '21 at 05:12
  • 1. I haven't tried other manufactures. I can do that. 2. I've tried different target SDKs–29, 30, and 31. I've gotten the same results with all of them. – George Nov 26 '21 at 05:39
  • Which permissions did you use specifically? – Michael Kotzjan Nov 26 '21 at 05:45
  • Added an update – George Nov 26 '21 at 05:46
  • Not sure if it will help but try also adding ACCESS_COARSE_LOCATION and asking for permissions at runtime. Have a look at this as well: https://stackoverflow.com/questions/69848393/bluetooth-does-not-scan-near-by-devices-in-background-mode-android-11 – Youssif Saeed Nov 26 '21 at 07:55
  • And just confirming that on Samsung you have Settings->Connections->More Connection Settings->Nearby device scanning set to On – Morrison Chang Nov 26 '21 at 07:56
  • Nearby device scanning is set to on – George Nov 26 '21 at 22:22
  • I tried with ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION & ACCESS_FINE_LOCATION, and ACCESS_FINE_LOCATION. According to google's guide https://developer.android.com/guide/topics/connectivity/bluetooth/permissions here you only need ACCESS_FINE_LOCATION. But I tried both. – George Nov 26 '21 at 22:23

0 Answers0