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:
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" />