public class CustomTabsClient extends Object
CustomTabsService
and create
CustomTabsSession
from it.Modifier and Type | Method and Description |
---|---|
static boolean |
bindCustomTabsService(Context context,
String packageName,
CustomTabsServiceConnection connection)
Bind to a
CustomTabsService using the given package name and
ServiceConnection . |
static boolean |
connectAndInitialize(Context context,
String packageName)
Connects to the Custom Tabs warmup service, and initializes the browser.
|
Bundle |
extraCommand(String commandName,
Bundle args) |
static String |
getPackageName(Context context,
List<String> packages)
Returns the preferred package to use for Custom Tabs, preferring the default VIEW handler.
|
static String |
getPackageName(Context context,
List<String> packages,
boolean ignoreDefault)
Returns the preferred package to use for Custom Tabs.
|
CustomTabsSession |
newSession(CustomTabsCallback callback)
Creates a new session through an ICustomTabsService with the optional callback.
|
boolean |
warmup(long flags)
Warm up the browser process.
|
public static boolean bindCustomTabsService(Context context, String packageName, CustomTabsServiceConnection connection)
CustomTabsService
using the given package name and
ServiceConnection
.context
- Context
to use while calling
Context.bindService(Intent, ServiceConnection, int)
packageName
- Package name to set on the Intent
for binding.connection
- CustomTabsServiceConnection
to use when binding. This will
return a CustomTabsClient
on
#onCustomTabsServiceConnected(ComponentName, CustomTabsClient)
public static String getPackageName(Context context, @Nullable List<String> packages)
#getPackageName(Context, List, boolean)}.
public static String getPackageName(Context context, @Nullable List<String> packages, boolean ignoreDefault)
ignoreDefault
to true and give a
non empty list of package names in packages
.context
- Context
to use for querying the packages.packages
- Ordered list of packages to test for Custom Tabs support, in
decreasing order of priority.ignoreDefault
- If set, the default VIEW handler won't get priority over other browsers.null
.public static boolean connectAndInitialize(Context context, String packageName)
warmup()
and create a session. In this case, calling this method is not
necessary.context
- Context
to use to connect to the remote service.packageName
- Package name of the target implementation.public boolean warmup(long flags)
flags
- Reserved for future use.public CustomTabsSession newSession(CustomTabsCallback callback)
callback
- The callback through which the client will receive updates about the created
session. Can be null.CustomTabsSession.mayLaunchUrl(Uri, Bundle, List)
calls.
Null on error.