我有一个活动,将外部网址加载到我的应用内的网页视图中。我希望在可用时使用Chrome自定义标签,但我支持的设备可能没有支持它们的Chrome版本。如何检查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
}
此检查是否在其他浏览器中支持Chrome自定义选项卡? – X09