简体   繁体   中英

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. 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. 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.

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.

@andreban's answer was correct. 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+. But because you would send Intent.ACTION_VIEW , Android will launch the default browser. It just ignores all the parameters you put in the 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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