Issue
In my app I need access to 4 permissions (which are already declared in the manifest)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
In my code I check If I already have permissions, and if NOT:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(
arrayOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION), 1)
} else {
ActivityCompat.requestPermissions(this, arrayOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION), 1)
}
This code works in my emulator, which has a 29 API. But on my own device, the permissions popup won't show. Do you guys know why?
Solution
Any Android apps targeting API 30 are now no longer allowed to ask for BACKGROUND_PERMISSION at the same time as regular location permission. You have to split it into 2 seperate asks:
- Ask for regular foreground location permission, once granted,
- Ask for BACKGROUND_LOCATION permission on a new ask
Answered By - Geordie Wicks
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.