Android 17 how to implement the new "Location button" in XML?

1 day ago 4
ARTICLE AD BOX

jack mechi's user avatar

New contributor

jack mechi is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

5

Currently there doesn't appear to be a publicly available Jetpack library that adds the location button as-is, but from what I can tell the API surface is available at the android.app.permissionui package with an API that very closely resembles how the embedded photo picker APIs work (with sessions, clients, and IBinder tokens)

2026-04-18 16:19:17 +00:00

Commented 15 hours ago

My guess is that you might need to get an instance of LocationButtonProvider (from the factory class), then call the openSession method with the applicable parameters, where the client instance you pass to it will get the information needed to render the button in a SurfaceView

2026-04-18 16:23:31 +00:00

Commented 15 hours ago

The session data that is passed to onSessionOpened in your client implementation appears to have a getSurfacePackage method (returning a SurfaceControlViewHost.SurfacePackage) which you can use to get the button to actually be rendered (thankfully, SurfaceView has a handy setter method that accepts that return type)

2026-04-18 16:26:09 +00:00

Commented 15 hours ago

Please provide enough code so others can better understand or reproduce the problem.

2026-04-18 17:48:56 +00:00

Commented 14 hours ago

Read Entire Article