Almost every Android app has to open third party content
at some point.
At that moment, developers need to decide
if they open that content in the browser or use a web view.
Opening links in the browser is a heavyweight transition
from the application and doesn't allow you to customize the UI.
This may frustrate users and make it harder
for them to return to your app.
Using a web view gives you more control of the UI,
but it's harder to build and doesn't
include all the cool features that browser developers work
hard to provide.
Wouldn't it be nice if you could have the best of both worlds?
That's why we created Chrome Custom Tabs.
My name is Andre Bandarra, and with Chrome Custom Tabs,
third party content in your app is a first class citizen.
Chrome Custom Tabs is a new way to show third party content
on Android.
It allows you to change how Chrome looks and feels,
making the transition from app to web seamless.
By using Custom Tabs, you can customize
Chrome to match your application color, change the start
and exit animations, or add a custom action to the toolbar,
like a button to save an article to read later.
It also features a customizable Up button
that makes it easier for the user
to return to your app once done with the content.
Being a part of Chrome, it shares the same cookie jar
so your users won't have to log in frequently
to view third part content.
It also makes it easier for the content publishers
to track user engagement coming from your application.
You also get the Chrome features like form autofill, geolocation
prompts, and page translation.
But it's also about speed as it allows your app
to ask Chrome to preload content in the background
so that when users click on a link, it will open really fast.
Preloading content can make the links
inside your at open up to three times faster
than using a normal Chrome tab or web view.
Chrome Custom Tabs is already available
starting from Chrome version 45.
Let's take a look at how to use Chrome Custom
Tabs in your Android app.
First, add the Android Support Library to your project
build file.
To enable warm up and preloading,
you need to connect to browser service.
Once connected, you can ask Chrome to warm up.
To prefetch the contents, create a new navigation session,
optionally passing a callback.
Now you are ready to ask Chrome to prefetch the third party
content.
You can give it a single URL, or if you need more,
you can add a list of other URLs the user is likely to navigate.
Chrome will prioritize the first URL
followed by all other URLs on the list in the order passed
to it.
And don't forget to unbind the service when Chrome Custom
Tabs is no longer needed.
Now if possible, Chrome will start to prefetch the content.
It may go all the way from resolving
DNS to fetching the page and support content like CSS,
JavaScript, and images, and even prerender the page up
to the point that all that remains
is to actually draw the pixels on the screen.
You open a Chrome Tab by using a custom tab Intent.
Pass it a reference to the host activity and the URI
you want to open.
If the URI matches, one of the URIs [INAUDIBLE] prefetching,
Chrome will use prefetched contents.
Otherwise, it will fetch and render the page at that moment.
There are various customizations possible in the Custom Tab UI.
Use them by calling the corresponding methods
on the Custom Tabs Intent Builder.
To change the application bar color for instance,
you need to call the setToolbarColor methods.
Chrome Custom Tabs is a powerful tool
that allows your application to open
web content in a seamless way.
By using it, you get the UI flexibility of a web view,
increase the user retention, and create a seamless transition
between your app and the web.
You also get a shared cookie jar, form autofill,
and all the other cool features from Chrome,
improving even more the user experience
and providing better metrics for content publishers.
It also has the unique advantage of being
able to prefetch the content, making it load faster.
All those features make it the best solution
when opening third party content in your application.
It's also an open specification, which
means that other browsers besides Chrome is supported.
If you want to see how to integrate Chrome Custom
Tabs in your Android app, check out them on GitHub.
Or if you have questions, you can send them
on the Stack Overflow tag chrome-custom-tabs.
Next time you want third party content in your app,
let Chrome pick up the tab.
[MUSIC PLAYING]