altbeacon on Android 10 has simply stopped working. Are there any changes required especially to go to Android 10?
I have added the following permissions to my AndroidManifest.xml
<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>
<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\"/>
<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\" />
<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>
Looking at the app permissions, my app has the location and BT permissions granted while running. I start looking for beacons on onBeaconServiceConnect as prescribed at https://altbeacon.github.io/android-beacon-library/samples.html. What am I missing?
Android 10 adds new permissions requirements to do BLE scans and detect BLE beacons -- any app setting
targetSdkVersion 29or higher needs to obtain permissions as described below or no beacons will be detected. (If you settargetSdkVersion 28or earlier, these new requirements do not apply when running on Android 10, as Android grants the permissions automatically. This allows old apps to continue running unaffected after upgrading to Android 10.)The changes below are what you need to to if you set your project to
targetSdkVersion 29or higher:In addition to adding these permissions to the manifest:
You must also dynamically obtain the location permissions from the user as described here:
If you do not see this working, go to Settings -> Apps -> Your App -> Permissions and verify location had been granted.