Brifing

Android 17 Introduces Session-Based Location Access via System Button

New Jetpack Compose component simplifies location permission flow for developers and users.

ProAndroidDev - Medium3 min

1New Location Button in Android 17

Android 17 introduces a system-rendered location button that developers can embed in their apps via Jetpack Compose. This standardized UI element replaces custom location permission controls. When tapped, it triggers a system-managed permission flow that grants precise location access only for the current session, rather than persistent access. The feature requires declaring a new USE_LOCATION_BUTTON permission in the manifest alongside existing location permissions.

2Permission Model Changes

The traditional approach of requesting ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION at runtime is being supplemented with this new session-based model. Developers must include special flags (onlyForLocationButton) for the standard location permissions when implementing this feature. This creates a clear separation between session-based access (via the button) and traditional persistent location permissions, giving users more transparency about when apps access their location.

3Developer Benefits

The new system reduces permission-related boilerplate code by handling the complex UI and consent flow automatically. Developers simply declare the required permissions and add the LocationButton composable to their UI. The standardized appearance builds user trust through consistency across apps. Session-only access also makes permission requests more understandable to users compared to open-ended location access.

4Implementation Steps

To implement, developers must first add the new androidx-locationbutton-compose dependency (currently in alpha). The manifest requires declarations for both traditional location permissions (with special flags) and the new USE_LOCATION_BUTTON permission. The LocationButton composable can then be added to UI screens, with callbacks to handle permission grant/denial events. The system handles rendering on API 37+ devices, falling back to a local implementation on older versions.

5Customization Options

While providing a standardized appearance, the LocationButton offers extensive customization to match app branding. Developers can modify the color scheme (background, text, icon), outline style (border thickness and visibility), and size/shape (including corner radius). These customizations maintain the button's recognizable functionality while allowing visual integration with different app designs. Pressed states can also be customized for interactive feedback.

6Technical Implementation Details

The LocationButton composable accepts several parameters: onPermissionResult callback, backgroundColor, textColor, iconTint, strokeColor, strokeWidth, and various corner radius parameters. The component automatically handles different platform versions, using system rendering on Android Cinnamon Bun (API 37+) and falling back to local Compose rendering on older versions. This ensures consistent behavior across the Android ecosystem while leveraging newer platform capabilities where available.

7User Privacy Benefits

This change represents a significant privacy improvement by defaulting to session-only location access. Users gain clearer understanding of when apps access their location through the standardized button. The temporary nature of the access (limited to the current session) reduces risks of background location tracking. Google's documentation positions this as part of broader efforts to enhance location privacy controls in Android.

8Future Implications

The introduction of session-based location access signals a shift in Android's permission model towards more granular, context-aware controls. This approach could extend to other sensitive permissions in future versions. For developers, it represents an opportunity to build greater user trust through transparent data practices. The Jetpack Compose implementation also reinforces Google's push towards modern declarative UI development.

Original article: ProAndroidDev - Medium — Android 17 Introduces Session-Based Location Access via System Button