Chrome Custom Tabs for Android

Sascha Peilicke
Jun 14, 2017 · 2 min read

Working with Custom Tabs isn’t exactly straightforward. Even minimal examples involve quite a bit of code:

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!

Sascha Peilicke

Written by

Geek head. Music lover.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade