Android APIs
public abstract class

CustomTabsService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.support.customtabs.CustomTabsService

Class Overview

Abstract service class for implementing Custom Tabs related functionality. The service should be responding to the action ACTION_CUSTOM_TABS_CONNECTION. This class should be used by implementers that want to provide Custom Tabs functionality, not by clients that want to launch Custom Tabs.

Summary

Constants
String ACTION_CUSTOM_TABS_CONNECTION The Intent action that a CustomTabsService must respond to.
String KEY_URL For mayLaunchUrl(CustomTabsSessionToken, Uri, Bundle, List) calls that wants to specify more than one url, this key can be used with putParcelable(String, android.os.Parcelable) to insert a new url to each bundle inside list of bundles.
[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
CustomTabsService()
Public Methods
IBinder onBind(Intent intent)
Return the communication channel to the service.
Protected Methods
boolean cleanUpSession(CustomTabsSessionToken sessionToken)
Called when the client side IBinder for this CustomTabsSessionToken is dead.
abstract Bundle extraCommand(String commandName, Bundle args)
Unsupported commands that may be provided by the implementation.
abstract boolean mayLaunchUrl(CustomTabsSessionToken sessionToken, Uri url, Bundle extras, List<Bundle> otherLikelyBundles)
Tells the browser of a likely future navigation to a URL.
abstract boolean newSession(CustomTabsSessionToken sessionToken)
Creates a new session through an ICustomTabsService with the optional callback.
abstract boolean warmup(long flags)
Warms up the browser process asynchronously.
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

public static final String ACTION_CUSTOM_TABS_CONNECTION

The Intent action that a CustomTabsService must respond to.

Constant Value: "android.support.customtabs.action.CustomTabsService"

public static final String KEY_URL

For mayLaunchUrl(CustomTabsSessionToken, Uri, Bundle, List) calls that wants to specify more than one url, this key can be used with putParcelable(String, android.os.Parcelable) to insert a new url to each bundle inside list of bundles.

Constant Value: "android.support.customtabs.otherurls.URL"

Public Constructors

public CustomTabsService ()

Public Methods

public IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
  • Return an IBinder through which clients can call on to the service.

Protected Methods

protected boolean cleanUpSession (CustomTabsSessionToken sessionToken)

Called when the client side IBinder for this CustomTabsSessionToken is dead. Can also be used to clean up IBinder.DeathRecipient instances allocated for the given token.

Parameters
sessionToken The session token for which the IBinder.DeathRecipient call has been received.
Returns
  • Whether the clean up was successful. Multiple calls with two tokens holdings the same binder will return false.

protected abstract Bundle extraCommand (String commandName, Bundle args)

Unsupported commands that may be provided by the implementation.

Note:Clients should never rely on this method to have a defined behavior, as it is entirely implementation-defined and not supported.

This call can be used by implementations to add extra commands, for testing or experimental purposes.

Parameters
commandName Name of the extra command to execute.
args Arguments for the command
Returns

protected abstract boolean mayLaunchUrl (CustomTabsSessionToken sessionToken, Uri url, Bundle extras, List<Bundle> otherLikelyBundles)

Tells the browser of a likely future navigation to a URL. The method warmup(long) has to be called beforehand. The most likely URL has to be specified explicitly. Optionally, a list of other likely URLs can be provided. They are treated as less likely than the first one, and have to be sorted in decreasing priority order. These additional URLs may be ignored. All previous calls to this method will be deprioritized.

Parameters
sessionToken The unique identifier for the session. Can not be null.
url Most likely URL.
extras Reserved for future use.
otherLikelyBundles Other likely destinations, sorted in decreasing likelihood order. Each Bundle has to provide a url.
Returns
  • Whether the call was successful.

protected abstract boolean newSession (CustomTabsSessionToken sessionToken)

Creates a new session through an ICustomTabsService with the optional callback. This session can be used to associate any related communication through the service with an intent and then later with a Custom Tab. The client can then send later service calls or intents to through same session-intent-Custom Tab association.

Parameters
sessionToken Session token to be used as a unique identifier. This also has access to the CustomTabsCallback passed from the client side through getCallback().
Returns
  • Whether a new session was successfully created.

protected abstract boolean warmup (long flags)

Warms up the browser process asynchronously.

Parameters
flags Reserved for future use.
Returns
  • Whether warmup was/had been completed successfully. Multiple successful calls will return true.