CustomTabsService

public abstract class CustomTabsService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ androidx.browser.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

Nested classes

@interface CustomTabsService.Relation

 

@interface CustomTabsService.Result

 

Constants

String ACTION_CUSTOM_TABS_CONNECTION

The Intent action that a CustomTabsService must respond to.

String CATEGORY_COLOR_SCHEME_CUSTOMIZATION

An Intent filter category to signify that the Custom Tabs provider supports selecting and customizing color schemes via CustomTabsIntent.Builder.setColorScheme(int) and CustomTabsIntent.Builder.setColorSchemeParams(int, CustomTabColorSchemeParams).

String CATEGORY_NAVBAR_COLOR_CUSTOMIZATION

An Intent filter category to signify that the Custom Tabs provider supports customizing the color of the navigation bar (CustomTabsIntent.Builder.setNavigationBarColor(int)).

String CATEGORY_TRUSTED_WEB_ACTIVITY_IMMERSIVE_MODE

An Intent filter category to signify that the Trusted Web Activity provider supports immersive mode.

String CATEGORY_WEB_SHARE_TARGET_V2

An Intent filter category to signify that the Trusted Web Activity provider supports sending shared data according to the Web Share Target v2 protocol defined in https://wicg.github.io/web-share-target/level-2/.

int FILE_PURPOSE_TRUSTED_WEB_ACTIVITY_SPLASH_IMAGE

A constant to be used with CustomTabsSession.receiveFile(Uri, int, Bundle) indicating that the file is a splash image to be shown on top of a Trusted Web Activity while the web contents are loading.

String KEY_SUCCESS

The key to use to store a boolean in the returns bundle of extraCommand(String, Bundle) method, to indicate the command is executed successfully.

String KEY_URL

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

int RELATION_HANDLE_ALL_URLS

Used for CustomTabsSession.validateRelationship(int, Uri, Bundle).

int RELATION_USE_AS_ORIGIN

Used for CustomTabsSession.validateRelationship(int, Uri, Bundle).

int RESULT_FAILURE_DISALLOWED

Indicates that the postMessage request was not allowed due to a bad argument or requesting at a disallowed time like when in background.

int RESULT_FAILURE_MESSAGING_ERROR

Indicates that the postMessage request has failed due to an internal error on the browser message channel.

int RESULT_FAILURE_REMOTE_ERROR

Indicates that the postMessage request has failed due to a RemoteException .

int RESULT_SUCCESS

Indicates that the postMessage request was accepted.

String TRUSTED_WEB_ACTIVITY_CATEGORY

An Intent filter category to signify that the Custom Tabs provider supports Trusted Web Activities (see TrustedWebUtils for more details).

Inherited constants

Public constructors

CustomTabsService()

Public methods

IBinder onBind(Intent intent)

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 int postMessage(CustomTabsSessionToken sessionToken, String message, Bundle extras)

Sends a postMessage request using the origin communicated via requestPostMessageChannel(CustomTabsSessionToken, Uri).

abstract boolean receiveFile(CustomTabsSessionToken sessionToken, Uri uri, int purpose, Bundle extras)

Receive a file from client by given Uri, e.g.

abstract boolean requestPostMessageChannel(CustomTabsSessionToken sessionToken, Uri postMessageOrigin)

Sends a request to create a two way postMessage channel between the client and the browser linked with the given CustomTabsSession.

abstract boolean updateVisuals(CustomTabsSessionToken sessionToken, Bundle bundle)

Updates the visuals of custom tabs for the given session.

abstract boolean validateRelationship(CustomTabsSessionToken sessionToken, int relation, Uri origin, Bundle extras)

Request to validate a relationship between the application and an origin.

abstract boolean warmup(long flags)

Warms up the browser process asynchronously.

Inherited methods