Chrome 自定义选项卡是否需要用户下载 Chrome 应用程序?
Does Chrome Custom Tabs require the user to download the Chrome app?
为了使用 Chrome 自定义标签,您是否需要您的用户单独下载 Chrome(测试版),还是在您实施 Chrome 自定义标签时包含它进入您的应用程序?
要使自定义选项卡正常工作,用户需要安装支持自定义选项卡的浏览器。
从版本 45 开始,Chrome 已经可以使用了。
目前,Chrome是唯一支持它的浏览器,但由于它是一个开放协议,预计将来会有其他浏览器支持它。
@andreban 的回答是正确的。我只想详细说明一下。
是的,为了使自定义选项卡正常工作,用户确实需要 Chrome v45+。但是因为您将发送 Intent.ACTION_VIEW
,Android 将启动默认浏览器。它只是忽略您在 intent
.
中输入的所有参数
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.
If the user has Chrome installed and it is the default browser, it will automatically pick up the EXTRAS and present a customized UI. It is also possible for another browser to use the Intent extras to provide a similar customized interface.
当没有安装 Chrome 浏览器时,您可以根据需要选择使用 CustomTabFallback。您可以在此处为该案例实施替代解决方案:
/**
* 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);
}
}
这里我使用 Activity 加载 URL,它只使用 WebView,我只是将 Uri 传递给它。这真的取决于你需要什么。所以如果你愿意,你可以有多种回退类型。
为了使用 Chrome 自定义标签,您是否需要您的用户单独下载 Chrome(测试版),还是在您实施 Chrome 自定义标签时包含它进入您的应用程序?
要使自定义选项卡正常工作,用户需要安装支持自定义选项卡的浏览器。
从版本 45 开始,Chrome 已经可以使用了。
目前,Chrome是唯一支持它的浏览器,但由于它是一个开放协议,预计将来会有其他浏览器支持它。
@andreban 的回答是正确的。我只想详细说明一下。
是的,为了使自定义选项卡正常工作,用户确实需要 Chrome v45+。但是因为您将发送 Intent.ACTION_VIEW
,Android 将启动默认浏览器。它只是忽略您在 intent
.
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.
If the user has Chrome installed and it is the default browser, it will automatically pick up the EXTRAS and present a customized UI. It is also possible for another browser to use the Intent extras to provide a similar customized interface.
当没有安装 Chrome 浏览器时,您可以根据需要选择使用 CustomTabFallback。您可以在此处为该案例实施替代解决方案:
/**
* 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);
}
}
这里我使用 Activity 加载 URL,它只使用 WebView,我只是将 Uri 传递给它。这真的取决于你需要什么。所以如果你愿意,你可以有多种回退类型。