How to check if chrome is not enabled on user's device

1.1k views Asked by At

I am using Custom Tabs to launch web view.

The issue is that, if i disable chrome it opens the URL in an activity, which does not have any button in it.

I want to launch Web Browser, if chrome is not installed on your user device, and launch custom tab, if chrome is there.

This is my code to launch Custom Tabs

        CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
                .addDefaultShareMenuItem()
                .setShowTitle(true)
                .build();

// This is optional but recommended
        CustomTabsHelper.addKeepAliveExtra(eContext, customTabsIntent.intent);

// This is where the magic happens...
        CustomTabsHelper.openCustomTab(eContext, customTabsIntent,
                Uri.parse(url),
                new WebViewFallback());
1

There are 1 answers

0
shant On

This is to answer how you can check if chrome is disabled. ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("chrome_package_name", 0); boolean isAppEnabled = applicationInfo.enabled;

reference: https://developer.android.com/reference/android/content/pm/ApplicationInfo.html#enabled

Happy to help.