Getting started

Published on

The first step for a Custom Tabs integration is adding the AndroidX Browser Library to your project. Open the app/build.gradle file and add the browser library to the dependencies section.

dependencies {

implementation 'androidx.browser:browser:1.5.0'
}

Checkout the Android Custom Tab Sample app on Github for a working example.

With the androidx.browser/browser library installed, you can use the CustomTabsIntent.Builder to create a CustomTabsIntent and launch the Custom Tab by calling launchUrl() and passing an Uri:

String url = "https://developers.android.com";
CustomTabsIntent intent = new CustomTabsIntent.Builder()
.build();
intent.launchUrl(MainActivity.this, Uri.parse(url));

This will open a fullscreen Custom Tab activity as seen on the following screenshot.

The default Custom Tabs experience.
Important

What happens if the user's default browser does not support Custom Tabs? Custom Tabs are supported by most Android browsers, but if no browser that supports Custom Tabs is installed, the CustomTabIntent will open the user's default browser instead. This works, as the CustomTabsIntent uses the ACTION\_VIEW Intent with Extras key to customize the UI.

Next up: learn how to customize the look and feel of your Custom Tab..

Published on Improve article

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.