added in version 24.1.0
belongs to Maven artifact


public final class CustomTabsSession
extends Object


A class to be used for Custom Tabs related communication. Clients that want to launch Custom Tabs can use this class exclusively to handle all related communication.


Public methods

static CustomTabsSession createMockSessionForTesting(ComponentName componentName)

Provides browsers a way to generate a mock CustomTabsSession for testing purposes.

boolean mayLaunchUrl(Uri url, Bundle extras, List<Bundle> otherLikelyBundles)

Tells the browser of a likely future navigation to a URL.

int postMessage(String message, Bundle extras)

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

boolean requestPostMessageChannel(Uri postMessageOrigin)

Sends a request to create a two way postMessage channel between the client and the browser.

boolean setActionButton(Bitmap icon, String description)

This sets the action button on the toolbar with ID TOOLBAR_ACTION_BUTTON_ID.

boolean setSecondaryToolbarViews(RemoteViews remoteViews, int[] clickableIDs, PendingIntent pendingIntent)

Updates the RemoteViews of the secondary toolbar in an existing custom tab session.

boolean setToolbarItem(int id, Bitmap icon, String description)

This method was deprecated in API level 25.1.0. Use CustomTabsSession#setSecondaryToolbarViews(RemoteViews, int[], PendingIntent)

boolean validateRelationship(int relation, Uri origin, Bundle extras)

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

Inherited methods

From class java.lang.Object

Public methods


added in version 27.1.0