public final class CustomTabsSession
extends Object

   ↳ androidx.browser.customtabs.CustomTabsSession

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 CustomTabsService.requestPostMessageChannel(CustomTabsSessionToken, Uri).

boolean receiveFile(Uri uri, int purpose, Bundle extras)

Passes an URI of a file, e.g.

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 CustomTabsIntent.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 is deprecated. 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