0

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:

enter image description here

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"
Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85
  • Please tell values of Build.VERSION.SDK_INT, Build.VERSION.RELEASE, Build.VERSION.PREVIEW_SDK_INT and Build.VERSION.RELEASE_OR_CODENAME. (And dont forget to comment on them). – blackapps Jun 11 '21 at 10:01
  • @blackapps I have added that now, don't really know what to make of it.. – Morten Holmgaard Jun 11 '21 at 10:27
  • Well how much does that look like Android 12 was what i asked. – blackapps Jun 11 '21 at 10:37
  • Not much. Just looked over https://developer.android.com/about/versions/12/get#on_emulator and I have missed the first step - using a preview version of Android Studio. – Morten Holmgaard Jun 11 '21 at 11:07
  • Yes, but.. i installed preview version but did not come any further. If you manage to launch a real Android 12 emulator then please report. – blackapps Jun 11 '21 at 11:11
  • @blackapps Yeah it didn't help me either. It might be related to the build tools version but when I try to use `buildToolsVersion "31.0.0-rc5"` it says that it is corrupted and should be reinstalled - but I have tried that multiple times without any change.. – Morten Holmgaard Jun 11 '21 at 12:55
  • 1
    Other problems: https://stackoverflow.com/questions/67935254/emulator-for-android-12-preview-no-connection?noredirect=1#comment120078607_67935254 – blackapps Jun 11 '21 at 13:33

1 Answers1

0

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

Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85