Background Location Permission

Background Location Access for Android 10 and Above

Android 10 and newer versions have introduced enhanced privacy controls, affecting how apps can access a user’s location in the background. This guide outlines the necessary permissions, explains Google’s changes, and describes how Netmera can assist in requesting background location access from users.

ACCESS_BACKGROUND_LOCATION

If your application needs to access the user’s location data while running in the background, you must include the ACCESS_BACKGROUND_LOCATION permission. This permission is essential for any background location tracking.

Understanding Google’s Privacy Changes

Starting with Android 10, Google introduced restrictions to improve privacy around location sharing, making it harder for apps to access location data in the background. The reasons for this change are:

💡 Privacy Enhancements

Android 10+ restricts apps from requesting background location permissions directly within the app. Users are only offered “Allow only while using the app” or “Deny” options when prompted. Google’s goal is to increase transparency and control over location data sharing.

💡 Increased User Control

Google encourages users to be more intentional about sharing their location. For apps to always have background location access, users must manually grant this permission in their settings:

Background Location Access Path for App Users:

Go to Settings > Apps > [Your App] > Permissions > Location and select “Allow always”.

How Netmera Supports Background Location Permission Requests

Netmera has implemented tools to help developers request background location access from users in a seamless way.

Using Netmera's Background Location Permission / n:blp Event

What It Does:

Netmera has defined an event, n:blp / background location permission event, that is triggered when the application requests ACCESS_BACKGROUND_LOCATION.

How It Works:

When this event is triggered, it can activate an automation scenario to guide users through granting background location permission. For example, a widget can be configured to show users a prompt about the permission requirements.

Background Location Permission Widget

This feature enables Netmera customers to display a widget that informs users about background location permissions. Here’s how to set it up:

  1. Create a Mobile Widget

Use the panel to create a widget that informs users about the need for background location access. Further information can be found on our User Documentation about how to create Widgets and Adding Click Actions.

  1. Configure Button Actions

Set up two button actions:

  • Allow Permission button: Directs users to Settings > Location so they can enable “Allow always”.

  • Deny Permission button: Provides the option to decline.

  1. Configure the n:blp Event

In your app’s code, request ACCESS_BACKGROUND_LOCATION. This will trigger the n:blp event automatically, activating any associated automations.

  1. Automate a Push Notification

Set up a push notification that’s triggered by the n:blp event. This can include a Handle Special Action option to prompt the user to allow background location access. Further information can be found on our User Documentation about Automation Scenarios and Handle Special Action.

Automation Settings:

When setting up the widget, we recommend selecting the "Only Once" option. This prevents the permission widget from repeatedly appearing for the user. Once the user grants the permission, the n:blp event will not be triggered again, meaning the widget won’t be shown multiple times. This approach ensures a smoother user experience by avoiding repetitive prompts for the same permission.

  1. Widget Display and Button Functionality:

When users tap the Update Setting button, the SDK redirects them to the device's settings to enable location access.

n:blp Event Trigger Conditions

The n:blp event will trigger when all of the following are true:

  • The device is running Android 10 or above,

  • The app includes background location permission in the manifest,

  • The app already has foreground location permission.

If both foreground and background permissions are granted, this event will not trigger.

Last updated