我有一个活动将外部网址加载到我的应用内的网页浏览中.我想在可用时使用Chrome自定义标签,但我支持的设备可能没有支持它们的Chrome版本.
在不支持CustomTabs的情况下,我想使用我的旧代码但是在它们使用时使用CustomTabsIntent.Builder().旧代码将内容加载到Activity中包含的WebView中,我仍然可以在其中管理ActionBar.
我想写一个帮助方法,告诉我它是否支持,但我不知道如何.开发者页面上的信息非常简洁:https: //developer.chrome.com/multidevice/android/customtabs
它表示如果您成功绑定,则可以安全地使用自定义选项卡.有没有一种简单的方法可以绑定来测试它?
像这样我假设:
Intent serviceIntent = new Intent("android.support.customtabs.action.CustomTabsService");
serviceIntent.setPackage("com.android.chrome");
boolean customTabsSupported = bindService(serviceIntent, new CustomTabsServiceConnection() {
            @Override
            public void onCustomTabsServiceConnected(final ComponentName componentName, final CustomTabsClient customTabsClient) {}
            @Override
            public void onServiceDisconnected(final ComponentName name) {}
        },
        Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY);
if (customTabsSupported) {
    // is supported
}