【问题标题】:How to check if chrome is not enabled on user's device如何检查用户设备上是否未启用 chrome
【发布时间】:2019-02-21 18:47:53
【问题描述】:

我正在使用Custom Tabs 启动web view

问题是,如果我禁用chrome,它会在一个没有任何按钮的活动中打开URL

如果您的用户设备上没有安装 chrome,我想启动 Web Browser,如果有 chrome,我想启动 custom tab

这是我启动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());

【问题讨论】:

标签: android performance android-layout android-webview android-customtabs


【解决方案1】:

这是为了回答如何检查 chrome 是否被禁用。 ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("chrome_package_name", 0); boolean isAppEnabled = applicationInfo.enabled;

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

乐于助人。

【讨论】:

    猜你喜欢
    • 2012-04-10
    • 1970-01-01
    • 2022-01-01
    • 2013-08-12
    • 2020-09-26
    • 2020-03-05
    • 2014-06-08
    • 2016-07-07
    • 2012-12-12
    相关资源
    最近更新 更多