I am trying to conform to the Android 12 changes to location permissions by handling the case of approximate location in the permission dialog. But when running this on a enumlator with Android S (android-S\google_apis\x86_64) I still get the same dialog as on previous versions of android:
This is my setup:
android {
compileSdkVersion "android-S"
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 23
targetSdkVersion "S"
...
}
...
}
Following the exact example from the documentation: https://developer.android.com/about/versions/12/approximate-location
val locationPermissionRequest = registerForActivityResult(
ActivityResultContracts.RequestMultiplePermissions()
) { permissions ->
when {
permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false) -> {
// Precise location access granted.
}
permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false) -> {
// Only approximate location access granted.
} else -> {
// No location access granted.
}
}
}
locationPermissionRequest.launch(arrayOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION))
Any idea what is missing to get the new location permission dialog?
Edit:
Build.VERSION.SDK_INT = 30
Build.VERSION.RELEASE = "11"
Build.VERSION.PREVIEW_SDK_INT = 1
Build.VERSION.RELEASE_OR_CODENAME = "S"
I got it working with the Android S Preview
Android SDK Platform S revision 5
, had revision 4
before in the SDK Manager.
It is working with the above posted Build.VERSION.SDK_INT ect.
But the network connection problem still seems to be there: Emulator for Android 12 preview no connection