Most visited

Recently visited

CustomTabsClient

public class CustomTabsClient
extends Object

java.lang.Object
   ↳ android.support.customtabs.CustomTabsClient


类与 CustomTabsService进行通信并 CustomTabsService创建 CustomTabsSession

Summary

Public methods

static boolean bindCustomTabsService(Context context, String packageName, CustomTabsServiceConnection connection)

绑定到 CustomTabsService使用给定的包名和 ServiceConnection

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

From class java.lang.Object

Public methods

bindCustomTabsService

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.

connectAndInitialize

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.

extraCommand

Bundle extraCommand (String commandName, 
                Bundle args)

Parameters
commandName String
args Bundle
Returns
Bundle

getPackageName

String getPackageName (Context context, 
                List<String> packages)

返回用于自定义选项卡的首选包,更喜欢默认的VIEW处理程序。

Parameters
context Context
packages List
Returns
String

也可以看看:

getPackageName

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.

newSession

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.

warmup

boolean warmup (long flags)

预热浏览器进程。 允许浏览器应用程序在后台自行初始化。 显着加快浏览器中的URL打开速度。 这是异步的,可以多次调用。

Parameters
flags long: Reserved for future use.
Returns
boolean Whether the warmup was successful.

Hooray!