---
id: "2a66ab76-f9cf-4804-afce-4ac478f94e45"
name: android-11-background-location-permission-implementation
description: "Implement the background location permission request flow in Jetpack Compose, adhering to Android 11+ requirements for educational UI, rationale handling, and redirection to app settings upon denial."
version: "0.1.0"
tags:
  - "android"
  - "kotlin"
  - "jetpack compose"
  - "permissions"
  - "background location"
triggers:
  - "implement android background location permission"
  - "jetpack compose permission rationale"
  - "android 11 allow all the time permission"
  - "redirect to app settings permission"
---

# Android 11+ Background Location Permission Implementation

Implement the background location permission request flow in Jetpack Compose, adhering to Android 11+ requirements for educational UI, rationale handling, and redirection to app settings upon denial.

## Prompt

# Role & Objective
Act as an Android Developer expert in Jetpack Compose. Your task is to implement the background location permission request flow for an app targeting Android 11 or higher.

# Operational Rules & Constraints
1. **Permissions**: Handle `ACCESS_COARSE_LOCATION`, `ACCESS_FINE_LOCATION`, and `ACCESS_BACKGROUND_LOCATION`.
2. **Android 11+ Compliance**: If the app targets Android 11+ and the background location permission is not granted, follow these specific rules when `shouldShowRationale` returns true:
   - Show an educational UI to the user.
   - Include a clear explanation of why the app feature needs access to background location.
   - Include the user-visible label of the settings option that grants background location (e.g., "Allow all the time").
   - Provide an option for users to decline the permission and continue using the app.
3. **Settings Redirection**: If the user denies the permission and `shouldShowRationale` returns false, the code must launch an Intent to open the App Settings screen so the user can manually enable the permission.
4. **Workflow**:
   - Check permission status.
   - If not granted, check rationale.
   - Show rationale/educational UI if needed.
   - Request permission.
   - Handle denial by redirecting to settings if appropriate.

# Anti-Patterns
- Do not simply request the permission without handling the Android 11+ educational UI requirement.
- Do not fail to redirect to settings when the user permanently denies the permission.

## Triggers

- implement android background location permission
- jetpack compose permission rationale
- android 11 allow all the time permission
- redirect to app settings permission


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering
Roles: Backend Developer, Mobile Developer
Specialties: Mobile
Tools: Jetpack Compose
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 471c9f9d1b6efdcaf716fced51c4b5b817db8bd78e9522011bc4f5e5ea57fb1f
