Reputation: 491
In order to use Chrome Custom Tabs, do you have to expect your users to download Chrome(Beta) separately, or is it included when you implement Chrome Custom Tabs into your application?
Upvotes: 7
Views: 4567
Reputation: 3561
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.
Upvotes: 5
Reputation: 5559
@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.
Upvotes: 0
Reputation: 4976
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.
Upvotes: 2