Chrome Custom Tabs for Android

Working with Custom Tabs isn’t exactly straightforward. Even minimal examples involve quite a bit of code as can be seen in the Official Chrome Custom Tabs documentation.

What makes it worse is that one can’t expect Chrome to be available on any device. That means additional code to fall back to good old WebView. To simplify the experience, there is a new library available that provides a higher-level interface that implements many often-needed convenience features:

To create a new CustomTabsIntent and start it with a keep-alive service as well as a fallback:

CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()

// This is optional but recommended
CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);

// This is where the magic happens...
CustomTabsHelper.openCustomTab(this, customTabsIntent,
        new WebViewFallback());

Preload CustomTabs in your to warm-up early and reduce start-up time:

// Preload custom tabs service for improved performance
// This is optional but recommended

This is how it looks:

Now Custom Tabs are great again!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.