简体   繁体   English

Chrome自定义标签是否要求用户下载Chrome应用?

[英]Does Chrome Custom Tabs require the user to download the Chrome app?

要使用Chrome自定义标签,您是否希望用户单独下载Chrome(测试版),还是将Chrome自定义标签应用到您的应用中时是否包含在内?

When there is no Chrome browser Installed, you can alternative use the CustomTabFallback if you like. 如果没有安装Chrome浏览器,您可以选择使用CustomTabFallback。 Here you can implement alternative solutions for that case: 在这里,您可以为该案例实施替代解决方案:

/**
 * A Fallback that opens the WebviewActivity when Custom Tabs is not available
 */
public final class WebviewFallback implements CustomTabActivityHelper.CustomTabFallback {

@Override
public void openUri(final Activity activity, final Uri uri) {
    final Intent intent = new Intent(activity, WebviewActivity.class);
    intent.putExtra(WebviewActivity.EXTRA_URL, uri.toString());
    activity.startActivity(intent);
}

} }

Here i use an Activity to load the URL, which just uses an WebView,i just pass the Uri to it. 在这里我使用一个Activity加载URL,它只使用一个WebView,我只是将Uri传递给它。 It really depends what you need. 这真的取决于你的需求。 So you can have multiple fallback types if you like. 因此,如果您愿意,可以使用多种后备类型。

For Custom Tabs to work, the user needs to have a browser that supports Custom Tabs installed. 要使自定义选项卡起作用,用户需要安装支持自定义选项卡的浏览器。

It is already available on the production Chrome, since version 45. 自版本45以来,它已在Chrome生产版上提供。

Currently, Chrome is the only browser that supports it, but as it's an open protocol, other browsers are expected to support it in the future. 目前,Chrome是唯一支持它的浏览器,但由于它是一种开放式协议,预计其他浏览器将来会支持它。

@andreban's answer was correct. @andreban的回答是正确的。 I'd just like to elaborate a little bit more. 我想再详细说明一下。

Yes, in order for Custom Tabs to work, the user does need to have a Chrome v45+. 是的,为了使自定义标签能够正常工作,用户需要拥有Chrome v45 +。 But because you would send Intent.ACTION_VIEW , Android will launch the default browser. 但是因为你会发送Intent.ACTION_VIEW ,Android会启动默认浏览器。 It just ignores all the parameters you put in the intent . 它只是忽略了你在intent放入的所有参数。

From documentation : 来自文档

We are using the ACTION_VIEW Intent, this means that by default the page will open in the system browser, or the user's default browser. 我们正在使用ACTION_VIEW Intent,这意味着默认情况下页面将在系统浏览器或用户的默认浏览器中打开。

If the user has Chrome installed and it is the default browser, it will automatically pick up the EXTRAS and present a customized UI. 如果用户安装了Chrome并且它是默认浏览器,它将自动获取EXTRAS并显示自定义UI。 It is also possible for another browser to use the Intent extras to provide a similar customized interface. 另一个浏览器也可以使用Intent附加功能来提供类似的自定义界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM