Request Location Permission Correctly in Android 11.

Best practices for requesting background location in Android.

Lam Pham
The Startup

--

Android Location in background
Photo by Jake Davies on Unsplash

Since location has now become sensitive data, Android restricts its usage, especially in background apps.

Before Android 9, there was no diversion of location permission. Foreground and background apps used the same resource.

However, Google started to realise that apps were abusing this type of data, they decided to add a few layers to protect users by separating location resources into background and foreground.

As a result, this adds a few extra work for Android developers to require location permission in their apps.

Before going into detail, let’s take a look at the changelogs in several latest Android versions.

  • From Android 8 (≥8): background apps can only retrieve user’s location a few times each hour.
  • Prior to Android 10(<10), location permission was a single resource: apps only required permission once to use everywhere (foreground and background) and every time.
  • From Android 10(≥10), background location came as an independent resource. Apps have to request explicitly this permission besides the foreground one.
  • From Android 11(≥11), background…

--

--