Most visited

Recently visited

CustomTabsService

public abstract class CustomTabsService
extends Service

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


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.

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 updateVisuals(CustomTabsSessionToken sessionToken, Bundle bundle)

Updates the visuals of custom tabs for the given session.

abstract boolean warmup(long flags)

Warms up the browser process asynchronously.

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

ACTION_CUSTOM_TABS_CONNECTION

String ACTION_CUSTOM_TABS_CONNECTION

The Intent action that a CustomTabsService must respond to.

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

KEY_URL

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

CustomTabsService

CustomTabsService ()

Public methods

onBind

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 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
IBinder Return an IBinder through which clients can call on to the service.

Protected methods

cleanUpSession

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 CustomTabsSessionToken: The session token for which the IBinder.DeathRecipient call has been received.
Returns
boolean Whether the clean up was successful. Multiple calls with two tokens holdings the same binder will return false.

extraCommand

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 String: Name of the extra command to execute.
args Bundle: Arguments for the command
Returns
Bundle The result Bundle, or null.

mayLaunchUrl

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 CustomTabsSessionToken: The unique identifier for the session. Can not be null.
url Uri: Most likely URL.
extras Bundle: Reserved for future use.
otherLikelyBundles List: Other likely destinations, sorted in decreasing likelihood order. Each Bundle has to provide a url.
Returns
boolean Whether the call was successful.

newSession

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 CustomTabsSessionToken: Session token to be used as a unique identifier. This also has access to the CustomTabsCallback passed from the client side through getCallback().
Returns
boolean Whether a new session was successfully created.

updateVisuals

boolean updateVisuals (CustomTabsSessionToken sessionToken, 
                Bundle bundle)

Updates the visuals of custom tabs for the given session. Will only succeed if the given session matches the currently active one.

Parameters
sessionToken CustomTabsSessionToken: The currently active session that the custom tab belongs to.
bundle Bundle: The action button configuration bundle. This bundle should be constructed with the same structure in CustomTabsIntent.Builder.
Returns
boolean Whether the operation was successful.

warmup

boolean warmup (long flags)

Warms up the browser process asynchronously.

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

Hooray!