Stay organized with collections Save and categorize content based on your preferences.
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'
}
Note: Checkout the Android Custom Tab Sample app on Github for a working example. Open a link in a Custom Tab
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.
Key point: 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, theCustomTabIntent
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. Supporting Android App Links
By default, Custom Tabs support Android App Links. This means, if the YouTube app is installed, launching a CustomTabsIntent
with a YouTube video URL will open the YouTube app instead of the browser.
However, passing a CustomTabsSession
to a CustomTabIntent
will force open the link in a Custom Tab, even if the corresponding native app is installed. If you want to keep the default behavior of opening web links in native apps, you need to additionally follow our guide on how to check if a link can be handled by an installed native app.
Next up: learn how to customize the look and feel of your Custom Tab..
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-04-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-04-21 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4