Added in API level 37

LocationButtonProvider


interface LocationButtonProvider
android.app.permissionui.LocationButtonProvider

The primary entry point for the Location Button API.

This interface allows an application to request a system-rendered button that, when tapped, grants the app temporary/one-time permission to access the user's precise location. It provides a trusted and standardized way for users to share their location for a specific task.

Instances of this interface are obtained from LocationButtonProviderFactory.

Summary

Public methods
abstract Unit
openSession(activity: Activity, hostToken: IBinder, displayId: Int, request: LocationButtonRequest, clientExecutor: Executor, client: LocationButtonClient)

Asynchronously requests a new Location Button session.

Public methods

openSession

Added in API level 37
abstract fun openSession(
    activity: Activity,
    hostToken: IBinder,
    displayId: Int,
    request: LocationButtonRequest,
    clientExecutor: Executor,
    client: LocationButtonClient
): Unit

Asynchronously requests a new Location Button session.

This method initiates a request to the system to create a location button. The button's UI is rendered in a separate process and embedded within the application's view hierarchy. User interaction with the button is handled securely by the system.

The outcome of this request, including the created LocationButtonSession or any errors, is delivered asynchronously to the provided LocationButtonClient.

Parameters
activity Activity: Host app activity which launch permission activity in its task.
This value cannot be null.
hostToken IBinder: A token for the host window.
This value cannot be null.
displayId Int: The ID of the display where the button will appear.
request LocationButtonRequest: A LocationButtonRequest defining the button's appearance.
This value cannot be null.
clientExecutor Executor: The Executor on which to invoke all client callbacks.
This value cannot be null.
client LocationButtonClient: The LocationButtonClient to receive session events and results.
This value cannot be null.