Member-only story

Retrieving the URL from Custom Tabs in Android

Code on the Rocks
4 min readJun 5, 2020

--

Check out the full series on Custom Tabs:

In my previous article I provided an overview of Custom Tabs, or Chrome Custom Tabs, in Android. In short, this component allows your app to seamlessly transition between application and web content and it’s used by several well known applications including Twitter, The Gaurdian, Tumblr, Stack Overflow, and Feedly. They’re safe, simple to use, and their ability to preemptively load URLS makes them incredibly fast compared to alternatives like WebViews. With this said, using Custom Tabs is the preferred option if you want to give users access to the web without sending them to another app. You can be up and running with a few lines of code.

This all sounds pretty convenient and depending on how you plan to use the browser, it might be. The biggest inconvenience that I’ve discovered is that the Custom Tab’s current URL is not sent back to the host application and retrieving it is not the most intuitive process. Apparently this behavior was put in place to safegaurd the user’s privacy and that makes sense…but what if you want to implement a custom share button? Or you want to trigger an action when the user navigates to a specific website? Not all of the use cases for URL tracking are immediately obvious but a lot of people have inquired about…

--

--

No responses yet