Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# LocationButtonProvider

*** ** * ** ***

` public interface LocationButtonProvider `   
` `

|---|
| android.app.permissionui.LocationButtonProvider |

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/android/app/permissionui/LocationButtonProviderFactory`.
**See also:**

- `https://developer.android.com/reference/android/app/permissionui/LocationButtonProviderFactory`
- `https://developer.android.com/reference/android/app/permissionui/LocationButtonSession`
- `https://developer.android.com/reference/android/app/permissionui/LocationButtonClient`

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/app/permissionui/LocationButtonProvider#openSession(android.app.Activity,%20android.os.IBinder,%20int,%20android.app.permissionui.LocationButtonRequest,%20java.util.concurrent.Executor,%20android.app.permissionui.LocationButtonClient)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/IBinder hostToken, int displayId, https://developer.android.com/reference/android/app/permissionui/LocationButtonRequest request, https://developer.android.com/reference/java/util/concurrent/Executor clientExecutor, https://developer.android.com/reference/android/app/permissionui/LocationButtonClient client) ` Asynchronously requests a new Location Button session. |

## Public methods

### openSession

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void openSession (Activity activity, 
                IBinder hostToken, 
                int displayId, 
                LocationButtonRequest request, 
                Executor clientExecutor, 
                LocationButtonClient client)
```

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 `https://developer.android.com/reference/android/app/permissionui/LocationButtonSession` or any errors, is delivered asynchronously to the provided `https://developer.android.com/reference/android/app/permissionui/LocationButtonClient`.

<br />

| Parameters ||
|---|---|
| `activity` | `Activity`: Host app activity which launch permission activity in its task. This value cannot be `null`. <br /> |
| `hostToken` | `IBinder`: A token for the host window. This value cannot be `null`. <br /> |
| `displayId` | `int`: The ID of the display where the button will appear. <br /> |
| `request` | `LocationButtonRequest`: A `https://developer.android.com/reference/android/app/permissionui/LocationButtonRequest` defining the button's appearance. This value cannot be `null`. <br /> |
| `clientExecutor` | `Executor`: The `https://developer.android.com/reference/java/util/concurrent/Executor` on which to invoke all client callbacks. This value cannot be `null`. <br /> |
| `client` | `LocationButtonClient`: The `https://developer.android.com/reference/android/app/permissionui/LocationButtonClient` to receive session events and results. This value cannot be `null`. <br /> |