vrund purohit vrund purohit - 1 year ago 114
Android Question

custom chrome tabs asks for multiple browser to choose

I am trying to implement custom chrome tabs. I am using Google's default library customtabs.

I referred this tutorial for implementing custom chrome tabs. now as suggested in tutorial, I did my coding something like this.

mCustomTabsServiceConnection = new CustomTabsServiceConnection() {
public void onCustomTabsServiceConnected(
ComponentName componentName,
CustomTabsClient customTabsClient) {
mCustomTabsClient = customTabsClient;
mCustomTabsSession = mCustomTabsClient.newSession(null);

public void onServiceDisconnected(ComponentName name) {
mCustomTabsClient = null;

CustomTabsClient.bindCustomTabsService(this, "com.android.chrome",

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(
builder.setStartAnimations(getApplicationContext(), R.anim.fadein,
builder.setExitAnimations(getApplicationContext(), R.anim.fadein,
mCustomTabsIntent = builder.build();

and launching custom tabs.


Now as you see I have bind custom tabs with chrome's package name, still it asks for choosing between Chrome and UC Browser. and it is obvious UC browser doesn't supports Custom tabs.

So my Question is how to restrict Custom tabs to bind only with Chrome Browser?

any help will be appreciated.

Thank you.

Answer Source

Check this stackoverflow answer: if you set the CustomTabIntent package with the package of your desired browser before launch the url, you can skip the Android dialog browser choice; for me it worked:

 * Opens the URL on a Custom Tab
 * @param activity         The host activity.
 * @param uri              the Uri to be opened.
public static void openCustomTab(Activity activity,
                                 Uri uri) {
    // Here is a method that returns the chrome package name 
    String packageName = CustomTabsHelper.getPackageNameToUse(activity, mUrl);

    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    mCustomTabsIntent = builder
    builder.setToolbarColor(ContextCompat.getColor(activity, R.color.colorPrimary));

    if ( packageName != null ) {
    mCustomTabsIntent.launchUrl(activity, uri);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download