I am having some trouble with asking for FINE_LOCATION in my app. I have tried to read a bit about ACCESS_FINE_LOCATION and i know i should ask for it together with ACCESS_COARSE_LOCATION for android 12, but it seems to only show me the "approximate location" everytime i ask. It doesnt even ask for FINE_LOCATION.
Here is my code
Manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Code:
//asking for permission inside a method
requestMultiplePermissions.launch(arrayOf(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION ))
// registering activity for result.
activity.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions ->
if(permissions.entries.all { it.value }){
checkPermissionsAndContinue()
}else{
val deniedPermission = permissions.entries.find { !it.value }
deniedPermission?.key?.let { showPermissionDeniedDialog(it) }
}
I have tried to run on android 31 emulator and my phone on android 12. Same result. Never get the fine location, just the coarse location. It seems to work fine for all other android versions, its just the android 12 fine location stuff thats stopping me.
Does someone have a idea where i could take a look to fix this? Thank you so much!
Thanks to lasagnakid77 i finally got it to work, thanks!
Just add tools:remove="android:maxSdkVersion" to the LOCATION_PERMISSION like so:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:remove="android:maxSdkVersion" />
A good explanantion why is here:Android 12 not showing correct permissions request screen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With