Check if an Android device has a browser that supports Custom Tabs?
Stay organized with collections
Save and categorize content based on your preferences.
If you want to know whether the default browser or any browser on a device supports Custom Tabs, use the getPackageName
helper in CustomTabsClient
:
String packageName = CustomTabsClient.getPackageName(
context,
Collections.emptyList()
);
if (packageName == null) {
// Custom Tabs are not supported by the default browser
}
You can also check if any browser on the device supports Custom Tabs:
// Get all apps that can handle VIEW intents and Custom Tab service connections.
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
PackageManager packageManager = context.getPackageManager();
List<ResolveInfo> viewIntentHandlers = packageManager.queryIntentActivities(activityIntent, 0);
// Get a package that supports Custom Tabs
String packageName = CustomTabsClient.getPackageName(
context,
viewIntentHandlers,
true /* ignore default */
);
if (packageName == null) {
// Custom Tabs are not supported by any browser on the device
}
Android 11 has introduced package visibility changes. If your Android app is targeting API level 30 or above, adding the following queries section to AndroidManifest.xml
is needed, otherwise the code snippet above won't return results:
<queries>
<intent>
<action android:name=
"android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
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 2020-02-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2020-02-04 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 2020-02-04 UTC."],[],[]]