public class CustomTabsClient
extends Object
| java.lang.Object | |
| android.support.customtabs.CustomTabsClient | |
类与 CustomTabsService进行通信并 CustomTabsService创建 CustomTabsSession 。
公共方法(Public methods) |
|
|---|---|
static boolean |
bindCustomTabsService(Context context, String packageName, CustomTabsServiceConnection connection) 绑定到 |
static boolean |
connectAndInitialize(Context context, String packageName) 连接到自定义选项卡热身服务,并初始化浏览器。 |
Bundle |
extraCommand(String commandName, Bundle args) |
static String |
getPackageName(Context context, List<String> packages) 返回用于自定义选项卡的首选包,更喜欢默认的VIEW处理程序。 |
static String |
getPackageName(Context context, List<String> packages, boolean ignoreDefault) 返回用于自定义选项卡的首选包。 |
CustomTabsSession |
newSession(CustomTabsCallback callback) 通过具有可选回调的ICustomTabsService创建新会话。 |
boolean |
warmup(long flags) 预热浏览器进程。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
boolean bindCustomTabsService (Context context, String packageName, CustomTabsServiceConnection connection)
绑定到 CustomTabsService使用给定的包名和 ServiceConnection 。
| 参数(Parameters) | |
|---|---|
context |
Context: Context to use while calling bindService(Intent, ServiceConnection, int) |
packageName |
String: Package name to set on the Intent for binding. |
connection |
CustomTabsServiceConnection: CustomTabsServiceConnection to use when binding. This will return a CustomTabsClient on #onCustomTabsServiceConnected(ComponentName, CustomTabsClient) |
| 返回(Returns) | |
|---|---|
boolean |
Whether the binding was successful. |
boolean connectAndInitialize (Context context, String packageName)
连接到自定义选项卡热身服务,并初始化浏览器。 这种便捷方法连接到服务,并立即升温自定义选项卡实现。 由于服务连接是异步的,返回码不是热身的返回码。 此呼叫是可选的,我们鼓励客户连接到服务,呼叫warmup()并创建会话。 在这种情况下,调用这个方法是没有必要的。
| 参数(Parameters) | |
|---|---|
context |
Context: Context to use to connect to the remote service. |
packageName |
String: Package name of the target implamentation. |
| 返回(Returns) | |
|---|---|
boolean |
Whether the binding was successful. |
Bundle extraCommand (String commandName, Bundle args)
| 参数(Parameters) | |
|---|---|
commandName |
String
|
args |
Bundle
|
| 返回(Returns) | |
|---|---|
Bundle |
|
String getPackageName (Context context, List<String> packages)
返回用于自定义选项卡的首选包,更喜欢默认的VIEW处理程序。
| 参数(Parameters) | |
|---|---|
context |
Context
|
packages |
List
|
| 返回(Returns) | |
|---|---|
String |
|
String getPackageName (Context context, List<String> packages, boolean ignoreDefault)
返回用于自定义选项卡的首选包。 只要它支持自定义选项卡,首选的包名称就是默认的VIEW意图处理程序。 要修改此首选行为,请将ignoreDefault设置为true,并在packages给出非空的包名称列表。
| 参数(Parameters) | |
|---|---|
context |
Context: Context to use for querying the packages. |
packages |
List: Ordered list of packages to test for Custom Tabs support, in decreasing order of priority. |
ignoreDefault |
boolean: If set, the default VIEW handler won't get priority over other browsers. |
| 返回(Returns) | |
|---|---|
String |
The preferred package name for handling Custom Tabs, or null. |
CustomTabsSession newSession (CustomTabsCallback callback)
通过具有可选回调的ICustomTabsService创建新会话。 此会话可用于通过服务与意图关联任何相关通信,然后再通过自定义标签关联。 然后,客户端可以通过相同的会话意向 - 自定义选项卡关联发送稍后的服务调用或意向。
| 参数(Parameters) | |
|---|---|
callback |
CustomTabsCallback: The callback through which the client will receive updates about the created session. Can be null. |
| 返回(Returns) | |
|---|---|
CustomTabsSession |
The session object that was created as a result of the transaction. The client can use this to relay mayLaunchUrl(Uri, Bundle, List) calls. Null on error. |
boolean warmup (long flags)
预热浏览器进程。 允许浏览器应用程序在后台自行初始化。 显着加快浏览器中的URL打开速度。 这是异步的,可以多次调用。
| 参数(Parameters) | |
|---|---|
flags |
long: Reserved for future use. |
| 返回(Returns) | |
|---|---|
boolean |
Whether the warmup was successful. |