Translated fromDeveloper.android.com/about/versi…

Android 12 has new features based on recent location permissions changes (background location and only this time). When an app targetsDK is upgraded to Android 12, the user can give the app an approximate location information, even if the app has been granted ACCESS_FINE_LOCATION permission.

If your app only applies for ACCESS_COARSE_LOCATION but not ACCESS_FINE_LOCATION, the pop-up description for permission requests will change accordingly. Here is an example of an app promoted to Android 12 with only ACCESS_COARSE_LOCATION permission:



To better protect user privacy, you are advised to apply only for ACCESS_COARSE_LOCATION. The App can cover most scenarios with general location information.

If your app target is raised to Andorid 12 and you have ACCESS_FINE_LOCATION, you must also have ACCESS_COARSE_LOCATION. You must include both permissions in the same run request. If you try to apply only for ACCESS_FINE_LOCATION, the request will be ignored and the system will log to you: ACCESS_FINE_LOCATION must be requested with ACCESS_COARSE_LOCATION.

The user chooses between approximate and exact location

When your App applies for both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION, the system permissions prompt will present the user with the following new options:

  • Precision: Provides the precise location corresponding to the ACCESS_FINE_LOCATION permission
  • General: Provides an approximate location for the ACCESS_COARSE_LOCATION permission

The following image shows two options for the user to choose from:



When the user has decided on a location, he then needs to continue to select one of the bottom three options to complete the permissions. These three options are the same as the permission prompt in Android 11.

In Android 12, users have the option of setting location accuracy for all apps in Settings, regardless of the App SDK version. This is even if your app was installed on Android 11 or earlier and then upgraded to Android 12. If a user changes the location access permission of an application from Exact to Approximate from the permissions dialog box or system Settings, the system restarts the application process. So it’s important for developers to followrequesting runtime permissionsTo get the best experience.

The user chooses to grant the effective permission

The following list shows the permissions granted to app by the system, which are based on the user’s choice in the permission application prompt box:

The precise approximate
When using this App ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION
Only the ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION
Refused to No Location permission No Location permission

To determine what permissions are currently granted to your App, you can check the return value of the permission request. You can use the Jetpack library in the example below, or you can use the platform library for permission requests and return value retrieval. For details, see manage the Permission Request Code Yourself

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.
            }
        }
    }

// ...

// Before you perform the actual permission request, check whether your app
// already has the permissions, and whether your app needs to show a permission
// rationale dialog. For more details, see Request permissions.
locationPermissionRequest.launch(arrayOf(
    Manifest.permission.ACCESS_FINE_LOCATION,
    Manifest.permission.ACCESS_COARSE_LOCATION))
Copy the code

User selection can also affect background positioning

If the system assigns App ACCESS_BACKGROUND_LOCATION, the user’s selection in the location permission dialog box also affects background location. For example, if the user allows ACCESS_BACKGROUND_LOCATION, but only allows the foreground to use approximate location, then the App can only have approximate location permission in the background.

Upgrade to Precise location

Proximity may affect apps that rely on ACCESS_FINE_LOCATION permissions. When asking for user permission for precise positioning, make sure your App really needs such a high precision positioning. If your App needs to connect to nearby Bluetooth or WIFI, be sure to use companion Device Pairing or Bluetooth Permissions instead of ACCESS_FINE_LOCATION. To request users to upgrade your application’s location access from approximate to precise, do the following:

  1. Where necessary, clarify why such authority is required
  2. Again, both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions are obtained. Because the user has allowed the system to grant the recent positioning permission to the App before, the pop-up box of permission application is displayed differently this time, as shown below:

Test App using approximate location

To evaluate whether the app needs to be upgraded to support user customization of location accuracy, please complete the following test.

Handle popover approximate location requests

In order to confirm whether the App can handle the user’s demand to allow the App to locate recently through the pop-up window, please perform the following steps:

  1. Apply for both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions
  2. In the example shown in Figure 2 of this article, select the approximate location option at the top, and then select only at this application run time or only this time at the bottom.
  3. Verify that the App is working properly, in the case of only recent location.

Demoted from system Settings to Recent Location

To confirm whether the App can handle the user’s request to degrade precise location from Settings to approximate location, perform the following steps:

  1. Apply for both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions
  2. In the example shown in Figure 2 of this article, select the precise location option at the top, and then select either this application run only or this time only at the bottom.
  3. The Application Permission page is displayed
  4. Turn off precise location in the Application Permissions interface, as shown below:



5. Confirm whether the App works normally, in the case of only recent positioning.

Upgrade from system Settings to Precise location

To confirm that the App processing user has upgraded approximate location from Settings to exact location, perform the following steps:

  1. Apply for both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions
  2. In the example shown in Figure 2 of this article, select the approximate location option at the top, and then select only at this application run time or only this time at the bottom.
  3. The Application Permission page is displayed
  4. Open precise positioning in the Application Permissions interface, as shown below:



5. Confirm whether the App has received more accurate information

Check the SDK dependencies in the App to locate requirements

Checking whether an SDK exists in the App depends on the ACCESS_FINE_LOCATION permission. For information, see Getting to know the Behaviors of Your SDK Dependencies