To further protect user privacy, Android 11 adds one-time location access and changes how users grant background location access. These updates affect all apps that run on Android 11 and higher.
On Android 11 and higher, whenever your app requests access to foreground location, the system permissions dialog includes an option called Only this time, as shown in figure 1. This option give users more control over when an app can access location information.
Learn more about how the system handles one-time permissions.
Background location access
Android 11 changes how a feature in your app can gain access to background location. This section describes each of these changes.
If a feature in your app accesses location from the background, verify that such access is necessary. Consider getting the information that the feature needs in other ways. To learn more about background location access, see the Access location in the background page.
Request background location separately
As described in the guide on how to request location access at runtime, you should perform incremental location requests. If your app targets Android 11 or higher, the system enforces this best practice. If you request a foreground location permission and the background location permission at the same time, the system ignores the request and doesn't grant your app either permission.
Permission dialog changes
How to toggle
As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:
adb shell am compat enable (147316723|BACKGROUND_RATIONALE_CHANGE_ID) PACKAGE_NAME
adb shell am compat disable (147316723|BACKGROUND_RATIONALE_CHANGE_ID) PACKAGE_NAME
For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.
When a feature in your app requests background location on a device that runs Android 11 or higher, the system dialog doesn't include a button to enable background location access. In order to enable background location access, users must set the Allow all the time option for your app's location permission on a settings page, as described in the guide on how to Request background location.