CustomTabsIntent


public final class CustomTabsIntent


Class holding the Intent and start bundle for a Custom Tabs Activity.

Note: The constants below are public for the browser implementation's benefit. You are strongly encouraged to use CustomTabsIntent.Builder.

Summary

Nested types

public final class CustomTabsIntent.Builder

Builder class for CustomTabsIntent objects.

Constants

static final int

The Custom Tab Activity, when it behaves as a bottom sheet, can have its height manually resized by the user.

static final int

Applies the default height resize behavior for the Custom Tab Activity when it behaves as a bottom sheet.

static final int

The Custom Tab Activity, when it behaves as a bottom sheet, cannot have its height manually resized by the user.

static final int

Side sheet's default decoration type.

static final int

Side sheet with a divider line - the activity is bordered by a thin opaque line.

static final int

Side sheet with no decorations - the activity is not bordered by any shadow or divider line.

static final int

Side sheet with shadow decoration - the activity is bordered by a shadow effect.

static final int

Applies the default position for the Custom Tab Activity when it behaves as a side sheet.

static final int

Position the side sheet on the end side of the screen.

static final int

Position the side sheet on the start side of the screen.

static final int

Side sheet's default rounded corner configuration.

static final int

Side sheet with no rounded corners.

static final int

Side sheet with the inner top corner rounded (if positioned on the right of the screen, this will be the top left corner)

static final int

Same as CLOSE_BUTTON_POSITION_START.

static final int

Positions the close button at the end of the toolbar.

static final int

Positions the close button at the start of the toolbar.

static final int

Applies a dark color scheme to the user interface in the custom tab.

static final int

Applies a light color scheme to the user interface in the custom tab.

static final int

Applies either a light or dark color scheme to the user interface in the custom tab depending on the user's system settings.

static final String
EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"

Bundle used for adding a custom action button to the custom tab toolbar.

static final String
EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR = "androidx.browser.customtabs.extra.ACTIVITY_HEIGHT_RESIZE_BEHAVIOR"

Extra that, if set in combination with EXTRA_INITIAL_ACTIVITY_HEIGHT_PX, defines the height resize behavior of the Custom Tab Activity when it behaves as a bottom sheet.

static final String
EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_BREAKPOINT_DP"

Extra that, if set, allows you to set a custom breakpoint for the Custom Tab - a value, x, for which if the screen's width is higher than x, the Custom Tab will behave as a side sheet (if EXTRA_INITIAL_ACTIVITY_WIDTH_PX is set), otherwise it will behave as a bottom sheet (if EXTRA_INITIAL_ACTIVITY_HEIGHT_PX is set).

static final String
EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_DECORATION_TYPE"

Extra that, if set, allows you to set how you want to distinguish the Partial Custom Tab side sheet from the rest of the display.

static final String
EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION"

Extra that enables the maximization button on the side sheet Custom Tab toolbar.

static final String
EXTRA_ACTIVITY_SIDE_SHEET_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_POSITION"

Extra that specifies the position of the side sheet.

static final String
EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION"

Extra that, if set, allows you to choose which side sheet corners should be rounded, if any at all.

static final String
EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON"

Extra bitmap that specifies the icon of the back button on the toolbar.

static final String
EXTRA_CLOSE_BUTTON_POSITION = "androidx.browser.customtabs.extra.CLOSE_BUTTON_POSITION"

Extra that specifies the position of the close button on the toolbar.

static final String
EXTRA_COLOR_SCHEME = "androidx.browser.customtabs.extra.COLOR_SCHEME"

Extra (int) that specifies which color scheme should be applied to the custom tab.

static final String
EXTRA_COLOR_SCHEME_PARAMS = "androidx.browser.customtabs.extra.COLOR_SCHEME_PARAMS"

Extra that contains a SparseArray, mapping color schemes (except COLOR_SCHEME_SYSTEM) to Bundle representing CustomTabColorSchemeParams.

static final String
EXTRA_DEFAULT_SHARE_MENU_ITEM = "android.support.customtabs.extra.SHARE_MENU_ITEM"

This field is deprecated.

Use EXTRA_SHARE_STATE instead.

static final String
EXTRA_DISABLE_BACKGROUND_INTERACTION = "androidx.browser.customtabs.extra.DISABLE_BACKGROUND_INTERACTION"

Extra tha disables interactions with the background app when a Partial Custom Tab is launched.

static final String
EXTRA_DISABLE_BOOKMARKS_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_STAR_BUTTON"

Extra to disable the bookmarks button in the overflow menu.

static final String
EXTRA_DISABLE_DOWNLOAD_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_DOWNLOAD_BUTTON"

Extra to disable the download button in the overflow menu.

static final String
EXTRA_ENABLE_INSTANT_APPS = "android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS"

Extra that specifies whether Instant Apps is enabled.

static final String
EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"

Boolean extra that enables the url bar to hide as the user scrolls down the page

static final String
EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"

Bundle constructed out of ActivityOptionsCompat that will be running when the Activity that holds the custom tab gets finished.

static final String
EXTRA_INITIAL_ACTIVITY_HEIGHT_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_HEIGHT_PX"

Extra that, if set, makes the Custom Tab Activity's height to be x pixels, the Custom Tab will behave as a bottom sheet. x will be clamped between 50% and 100% of screen height.

static final String
EXTRA_INITIAL_ACTIVITY_WIDTH_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_WIDTH_PX"

Extra that, if set, makes the Custom Tab Activity's width to be x pixels, the Custom Tab will behave as a side sheet.

static final String
EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"

Use an ArrayList<Bundle> for specifying menu related params.

static final String
EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR"

Extra that contains the color of the navigation bar.

static final String
EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR"

Extra that contains the color of the navigation bar divider.

static final String
EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS"

Extra that specifies the RemoteViews showing on the secondary toolbar.

static final String
EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID"

Extra that specifies which View has been clicked.

static final String
EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT"

Extra that specifies the PendingIntent to be sent when the user clicks on the Views that is listed by EXTRA_REMOTEVIEWS_VIEW_IDS.

static final String
EXTRA_REMOTEVIEWS_VIEW_IDS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_VIEW_IDS"

Extra that specifies an array of View ids.

static final String
EXTRA_SECONDARY_TOOLBAR_COLOR = "android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR"

Extra that changes the background color for the secondary toolbar.

static final String
EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE = "androidx.browser.customtabs.extra.SECONDARY_TOOLBAR_SWIPE_UP_GESTURE"

Extra that specifies the PendingIntent to be sent when the user swipes up from the secondary (bottom) toolbar.

static final String
EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER = "android.support.customtabs.extra.SEND_TO_EXTERNAL_HANDLER"

Extra to favor sending initial urls to external handler apps, if possible.

static final String
EXTRA_SESSION = "android.support.customtabs.extra.SESSION"

Extra used to match the session.

static final String
EXTRA_SHARE_STATE = "androidx.browser.customtabs.extra.SHARE_STATE"

Extra (int) that specifies which share state should be applied to the custom tab.

static final String
EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON"

Extra boolean that specifies whether the custom action button should be tinted.

static final String
EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY"

Extra (int) that specifies state for showing the page title.

static final String
EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR"

Extra that changes the background color for the toolbar. colorRes is an int that specifies a Color, not a resource id.

static final String
EXTRA_TOOLBAR_CORNER_RADIUS_DP = "androidx.browser.customtabs.extra.TOOLBAR_CORNER_RADIUS_DP"

Extra that sets the toolbar's top corner radii in dp.

static final String
EXTRA_TOOLBAR_ITEMS = "android.support.customtabs.extra.TOOLBAR_ITEMS"

Listused for adding items to the top and bottom toolbars.

static final String
EXTRA_TRANSLATE_LANGUAGE_TAG = "androidx.browser.customtabs.extra.TRANSLATE_LANGUAGE_TAG"

Extra that specifies the target locale the Translate UI should be triggered with.

static final String
KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION"

Key that specifies the content description for the custom action button.

static final String
KEY_ICON = "android.support.customtabs.customaction.ICON"

Key that specifies the Bitmap to be used as the image source for the action button.

static final String
KEY_ID = "android.support.customtabs.customaction.ID"

Key that specifies the unique ID for an action button.

static final String
KEY_MENU_ITEM_TITLE = "android.support.customtabs.customaction.MENU_ITEM_TITLE"

Key for specifying the title of a menu item.

static final String
KEY_PENDING_INTENT = "android.support.customtabs.customaction.PENDING_INTENT"

Key that specifies the PendingIntent to launch when the action button or menu item was clicked.

static final int

Don't show any title.

static final int

Applies the default share settings depending on the browser.

static final int

Explicitly does not show a share option in the tab.

static final int

Shows a share option in the tab.

static final int

Shows the page title and the domain.

static final int

The ID allocated to the custom action button that is shown on the toolbar.

Public fields

final @NonNull Intent

An Intent used to start the Custom Tabs Activity.

final @Nullable Bundle

A Bundle containing the start animation for the Custom Tabs Activity.

Public methods

static int

Gets the Custom Tab Activity's resize behavior.

static @Dimension(unit = 0) int

Gets the breakpoint value in dp that will be used to decide if the Custom Tab will be displayed as a bottom sheet or as a side sheet.

static int

Gets the type of the decoration that will be used to separate the side sheet from the Custom Tabs embedder.

static int

Gets the position where the side sheet should be displayed on the screen.

static int

Gets the type of rounded corners that will be used for the side sheet.

static int

Gets the position of the close button.

static @NonNull CustomTabColorSchemeParams
getColorSchemeParams(@NonNull Intent intent, int colorScheme)

Retrieves the instance of CustomTabColorSchemeParams from an Intent for a given color scheme.

static @Dimension(unit = 1) int

Gets the Custom Tab Activity's initial height.

static @Dimension(unit = 1) int

Gets the Custom Tab Activity's initial width.

static int
static @Nullable PendingIntent
static @Dimension(unit = 0) int

Gets the toolbar's top corner radii in dp.

static @Nullable Locale

Gets the target locale for the Translate UI.

static boolean

Whether the Custom Tab Activity, when acting as a side sheet, can be maximized.

static boolean
static boolean
static boolean
static boolean
void
launchUrl(@NonNull Context context, @NonNull Uri url)

Convenience method to launch a Custom Tabs Activity.

static @NonNull Intent

Adds the necessary flags and extras to signal any browser supporting custom tabs to use the browser UI at all times and avoid showing custom tab like UI.

static boolean

Whether a browser receiving the given intent should always use browser UI and avoid using any custom tabs UI.

Constants

ACTIVITY_HEIGHT_ADJUSTABLE

Added in 1.5.0
public static final int ACTIVITY_HEIGHT_ADJUSTABLE = 1

The Custom Tab Activity, when it behaves as a bottom sheet, can have its height manually resized by the user.

ACTIVITY_HEIGHT_DEFAULT

Added in 1.5.0
public static final int ACTIVITY_HEIGHT_DEFAULT = 0

Applies the default height resize behavior for the Custom Tab Activity when it behaves as a bottom sheet.

ACTIVITY_HEIGHT_FIXED

Added in 1.5.0
public static final int ACTIVITY_HEIGHT_FIXED = 2

The Custom Tab Activity, when it behaves as a bottom sheet, cannot have its height manually resized by the user.

ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DEFAULT

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DEFAULT = 0

Side sheet's default decoration type. Same as ACTIVITY_SIDE_SHEET_DECORATION_TYPE_SHADOW.

ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DIVIDER

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DIVIDER = 3

Side sheet with a divider line - the activity is bordered by a thin opaque line.

ACTIVITY_SIDE_SHEET_DECORATION_TYPE_NONE

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_NONE = 1

Side sheet with no decorations - the activity is not bordered by any shadow or divider line.

ACTIVITY_SIDE_SHEET_DECORATION_TYPE_SHADOW

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_SHADOW = 2

Side sheet with shadow decoration - the activity is bordered by a shadow effect.

ACTIVITY_SIDE_SHEET_POSITION_DEFAULT

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_POSITION_DEFAULT = 0

Applies the default position for the Custom Tab Activity when it behaves as a side sheet. Same as ACTIVITY_SIDE_SHEET_POSITION_END.

ACTIVITY_SIDE_SHEET_POSITION_END

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_POSITION_END = 2

Position the side sheet on the end side of the screen.

ACTIVITY_SIDE_SHEET_POSITION_START

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_POSITION_START = 1

Position the side sheet on the start side of the screen.

ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_DEFAULT

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_DEFAULT = 0

Side sheet's default rounded corner configuration. Same as ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_NONE

ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_NONE

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_NONE = 1

Side sheet with no rounded corners.

ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_TOP

Added in 1.8.0
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_TOP = 2

Side sheet with the inner top corner rounded (if positioned on the right of the screen, this will be the top left corner)

CLOSE_BUTTON_POSITION_DEFAULT

Added in 1.5.0
public static final int CLOSE_BUTTON_POSITION_DEFAULT = 0

Same as CLOSE_BUTTON_POSITION_START.

CLOSE_BUTTON_POSITION_END

Added in 1.5.0
public static final int CLOSE_BUTTON_POSITION_END = 2

Positions the close button at the end of the toolbar.

CLOSE_BUTTON_POSITION_START

Added in 1.5.0
public static final int CLOSE_BUTTON_POSITION_START = 1

Positions the close button at the start of the toolbar.

COLOR_SCHEME_DARK

Added in 1.2.0
public static final int COLOR_SCHEME_DARK = 2

Applies a dark color scheme to the user interface in the custom tab. Colors set through EXTRA_TOOLBAR_COLOR may be darkened to match user expectations.

COLOR_SCHEME_LIGHT

Added in 1.2.0
public static final int COLOR_SCHEME_LIGHT = 1

Applies a light color scheme to the user interface in the custom tab.

COLOR_SCHEME_SYSTEM

Added in 1.2.0
public static final int COLOR_SCHEME_SYSTEM = 0

Applies either a light or dark color scheme to the user interface in the custom tab depending on the user's system settings.

EXTRA_ACTION_BUTTON_BUNDLE

Added in 1.2.0
public static final String EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"

Bundle used for adding a custom action button to the custom tab toolbar. The client should provide a description, an icon Bitmap and a PendingIntent for the button. All three keys must be present.

EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR

Added in 1.5.0
public static final String EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR = "androidx.browser.customtabs.extra.ACTIVITY_HEIGHT_RESIZE_BEHAVIOR"

Extra that, if set in combination with EXTRA_INITIAL_ACTIVITY_HEIGHT_PX, defines the height resize behavior of the Custom Tab Activity when it behaves as a bottom sheet. Default is ACTIVITY_HEIGHT_DEFAULT.

EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP

Added in 1.8.0
public static final String EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_BREAKPOINT_DP"

Extra that, if set, allows you to set a custom breakpoint for the Custom Tab - a value, x, for which if the screen's width is higher than x, the Custom Tab will behave as a side sheet (if EXTRA_INITIAL_ACTIVITY_WIDTH_PX is set), otherwise it will behave as a bottom sheet (if EXTRA_INITIAL_ACTIVITY_HEIGHT_PX is set). If this Intent Extra is not set the browser implementation should set as default value 840dp. If x is set to <600dp the browser implementation should default it to 600dp.

EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE

Added in 1.8.0
public static final String EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_DECORATION_TYPE"

Extra that, if set, allows you to set how you want to distinguish the Partial Custom Tab side sheet from the rest of the display. Options include shadow, a divider line, or no decoration.

EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION

Added in 1.8.0
public static final String EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION"

Extra that enables the maximization button on the side sheet Custom Tab toolbar.

EXTRA_ACTIVITY_SIDE_SHEET_POSITION

Added in 1.8.0
public static final String EXTRA_ACTIVITY_SIDE_SHEET_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_POSITION"

Extra that specifies the position of the side sheet. By default it is set to ACTIVITY_SIDE_SHEET_POSITION_END, which is on the right side in left-to-right layout.

EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION

Added in 1.8.0
public static final String EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION"

Extra that, if set, allows you to choose which side sheet corners should be rounded, if any at all. Options include top or none.

EXTRA_CLOSE_BUTTON_ICON

Added in 1.2.0
public static final String EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON"

Extra bitmap that specifies the icon of the back button on the toolbar. If the client chooses not to customize it, a default close button will be used.

EXTRA_CLOSE_BUTTON_POSITION

Added in 1.5.0
public static final String EXTRA_CLOSE_BUTTON_POSITION = "androidx.browser.customtabs.extra.CLOSE_BUTTON_POSITION"

Extra that specifies the position of the close button on the toolbar. Default is CLOSE_BUTTON_POSITION_DEFAULT.

EXTRA_COLOR_SCHEME

Added in 1.2.0
public static final String EXTRA_COLOR_SCHEME = "androidx.browser.customtabs.extra.COLOR_SCHEME"

Extra (int) that specifies which color scheme should be applied to the custom tab. Default is COLOR_SCHEME_SYSTEM.

EXTRA_COLOR_SCHEME_PARAMS

Added in 1.2.0
public static final String EXTRA_COLOR_SCHEME_PARAMS = "androidx.browser.customtabs.extra.COLOR_SCHEME_PARAMS"

Extra that contains a SparseArray, mapping color schemes (except COLOR_SCHEME_SYSTEM) to Bundle representing CustomTabColorSchemeParams.

EXTRA_DEFAULT_SHARE_MENU_ITEM

Added in 1.2.0
Deprecated in 1.3.0
public static final String EXTRA_DEFAULT_SHARE_MENU_ITEM = "android.support.customtabs.extra.SHARE_MENU_ITEM"

Boolean extra that specifies whether a default share button will be shown in the menu.

EXTRA_DISABLE_BACKGROUND_INTERACTION

Added in 1.7.0
public static final String EXTRA_DISABLE_BACKGROUND_INTERACTION = "androidx.browser.customtabs.extra.DISABLE_BACKGROUND_INTERACTION"

Extra tha disables interactions with the background app when a Partial Custom Tab is launched.

EXTRA_DISABLE_BOOKMARKS_BUTTON

Added in 1.7.0
public static final String EXTRA_DISABLE_BOOKMARKS_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_STAR_BUTTON"

Extra to disable the bookmarks button in the overflow menu.

EXTRA_DISABLE_DOWNLOAD_BUTTON

Added in 1.7.0
public static final String EXTRA_DISABLE_DOWNLOAD_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_DOWNLOAD_BUTTON"

Extra to disable the download button in the overflow menu.

EXTRA_ENABLE_INSTANT_APPS

Added in 1.2.0
public static final String EXTRA_ENABLE_INSTANT_APPS = "android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS"

Extra that specifies whether Instant Apps is enabled.

EXTRA_ENABLE_URLBAR_HIDING

Added in 1.2.0
public static final String EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"

Boolean extra that enables the url bar to hide as the user scrolls down the page

EXTRA_EXIT_ANIMATION_BUNDLE

Added in 1.2.0
public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"

Bundle constructed out of ActivityOptionsCompat that will be running when the Activity that holds the custom tab gets finished. A similar ActivityOptions for creation should be constructed and given to the startActivity() call that launches the custom tab.

EXTRA_INITIAL_ACTIVITY_HEIGHT_PX

Added in 1.5.0
public static final String EXTRA_INITIAL_ACTIVITY_HEIGHT_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_HEIGHT_PX"

Extra that, if set, makes the Custom Tab Activity's height to be x pixels, the Custom Tab will behave as a bottom sheet. x will be clamped between 50% and 100% of screen height. Bottom sheet does not take effect in landscape mode or in multi-window mode.

EXTRA_INITIAL_ACTIVITY_WIDTH_PX

Added in 1.8.0
public static final String EXTRA_INITIAL_ACTIVITY_WIDTH_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_WIDTH_PX"

Extra that, if set, makes the Custom Tab Activity's width to be x pixels, the Custom Tab will behave as a side sheet. A minimum width will be enforced, thus the width will be clamped as such (based on the window size classes as defined by the Android documentation):

  • Compact, window width <600dp - a side sheet will not be displayed.
  • Medium, window width >=600dp and <840 dp - between 50% and 100% of the window's width.
  • Expanded, window width >=840dp - between 33% and 100% of the window's width.
Android Size Classes

EXTRA_MENU_ITEMS

Added in 1.2.0
public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"

Use an ArrayList<Bundle> for specifying menu related params. There should be a separate Bundle for each custom menu item.

EXTRA_NAVIGATION_BAR_COLOR

Added in 1.2.0
public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR"

Extra that contains the color of the navigation bar. See setNavigationBarColor.

EXTRA_NAVIGATION_BAR_DIVIDER_COLOR

Added in 1.3.0
public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR"

Extra that contains the color of the navigation bar divider. See setNavigationBarDividerColor.

EXTRA_REMOTEVIEWS

Added in 1.2.0
public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS"

Extra that specifies the RemoteViews showing on the secondary toolbar. If this extra is set, the other secondary toolbar configurations will be overriden. The height of the RemoteViews should not exceed 56dp.

EXTRA_REMOTEVIEWS_CLICKED_ID

Added in 1.2.0
public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID"

Extra that specifies which View has been clicked. This extra will be put to the PendingIntent sent from Custom Tabs when a view in the RemoteViews is clicked

EXTRA_REMOTEVIEWS_PENDINGINTENT

Added in 1.2.0
public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT"

Extra that specifies the PendingIntent to be sent when the user clicks on the Views that is listed by EXTRA_REMOTEVIEWS_VIEW_IDS.

Note when this PendingIntent is triggered, it will have the current url as data field, also the id of the clicked View, specified by EXTRA_REMOTEVIEWS_CLICKED_ID.

EXTRA_REMOTEVIEWS_VIEW_IDS

Added in 1.2.0
public static final String EXTRA_REMOTEVIEWS_VIEW_IDS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_VIEW_IDS"

Extra that specifies an array of View ids. When these Views are clicked, a PendingIntent will be sent, carrying the current url of the custom tab as data.

Note that Custom Tabs will override the default onClick behavior of the listed Views. If you do not care about the current url, you can safely ignore this extra and use setOnClickPendingIntent instead.

EXTRA_SECONDARY_TOOLBAR_COLOR

Added in 1.2.0
public static final String EXTRA_SECONDARY_TOOLBAR_COLOR = "android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR"

Extra that changes the background color for the secondary toolbar. The value should be an int that specifies a Color, not a resource id.

EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE

Added in 1.7.0
public static final String EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE = "androidx.browser.customtabs.extra.SECONDARY_TOOLBAR_SWIPE_UP_GESTURE"

Extra that specifies the PendingIntent to be sent when the user swipes up from the secondary (bottom) toolbar.

EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER

Added in 1.7.0
public static final String EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER = "android.support.customtabs.extra.SEND_TO_EXTERNAL_HANDLER"

Extra to favor sending initial urls to external handler apps, if possible. A Custom Tab Intent from a Custom Tab session will always have the package set, so the Intent will always be to the browser. This extra can be used to allow the initial Intent navigation chain to leave the browser.

EXTRA_SESSION

Added in 1.2.0
public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION"

Extra used to match the session. This has to be included in the intent to open in a custom tab. This is the same IBinder that gets passed to ICustomTabsService#newSession. Null if there is no need to match any service side sessions with the intent.

EXTRA_SHARE_STATE

Added in 1.3.0
public static final String EXTRA_SHARE_STATE = "androidx.browser.customtabs.extra.SHARE_STATE"

Extra (int) that specifies which share state should be applied to the custom tab. Default is SHARE_STATE_DEFAULT.

EXTRA_TINT_ACTION_BUTTON

Added in 1.2.0
public static final String EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON"

Extra boolean that specifies whether the custom action button should be tinted. Default is false and the action button will not be tinted.

EXTRA_TITLE_VISIBILITY_STATE

Added in 1.2.0
public static final String EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY"

Extra (int) that specifies state for showing the page title. Default is NO_TITLE.

EXTRA_TOOLBAR_COLOR

Added in 1.2.0
public static final String EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR"

Extra that changes the background color for the toolbar. colorRes is an int that specifies a Color, not a resource id.

EXTRA_TOOLBAR_CORNER_RADIUS_DP

Added in 1.5.0
public static final String EXTRA_TOOLBAR_CORNER_RADIUS_DP = "androidx.browser.customtabs.extra.TOOLBAR_CORNER_RADIUS_DP"

Extra that sets the toolbar's top corner radii in dp. This will only have effect if the custom tab is behaving as a bottom sheet. Currently, this is capped at 16dp.

EXTRA_TOOLBAR_ITEMS

Added in 1.2.0
public static final String EXTRA_TOOLBAR_ITEMS = "android.support.customtabs.extra.TOOLBAR_ITEMS"

Listused for adding items to the top and bottom toolbars. The client should provide an ID, a description, an icon for each item. They may also provide a if the item is a button.

EXTRA_TRANSLATE_LANGUAGE_TAG

Added in 1.7.0
public static final String EXTRA_TRANSLATE_LANGUAGE_TAG = "androidx.browser.customtabs.extra.TRANSLATE_LANGUAGE_TAG"

Extra that specifies the target locale the Translate UI should be triggered with. The locale is represented as a well-formed IETF BCP 47 language tag.

KEY_DESCRIPTION

Added in 1.2.0
public static final String KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION"

Key that specifies the content description for the custom action button.

KEY_ICON

Added in 1.2.0
public static final String KEY_ICON = "android.support.customtabs.customaction.ICON"

Key that specifies the Bitmap to be used as the image source for the action button. The icon should't be more than 24dp in height (No padding needed. The button itself will be 48dp in height) and have a width/height ratio of less than 2.

KEY_ID

Added in 1.2.0
public static final String KEY_ID = "android.support.customtabs.customaction.ID"

Key that specifies the unique ID for an action button. To make a button to show on the toolbar, use TOOLBAR_ACTION_BUTTON_ID as its ID.

KEY_MENU_ITEM_TITLE

Added in 1.2.0
public static final String KEY_MENU_ITEM_TITLE = "android.support.customtabs.customaction.MENU_ITEM_TITLE"

Key for specifying the title of a menu item.

KEY_PENDING_INTENT

Added in 1.2.0
public static final String KEY_PENDING_INTENT = "android.support.customtabs.customaction.PENDING_INTENT"

Key that specifies the PendingIntent to launch when the action button or menu item was clicked. The custom tab will be calling send on clicks after adding the url as data. The client app can call getDataString to get the url.

NO_TITLE

Added in 1.2.0
public static final int NO_TITLE = 0

Don't show any title. Shows only the domain.

SHARE_STATE_DEFAULT

Added in 1.3.0
public static final int SHARE_STATE_DEFAULT = 0

Applies the default share settings depending on the browser.

SHARE_STATE_OFF

Added in 1.3.0
public static final int SHARE_STATE_OFF = 2

Explicitly does not show a share option in the tab.

SHARE_STATE_ON

Added in 1.3.0
public static final int SHARE_STATE_ON = 1

Shows a share option in the tab.

SHOW_PAGE_TITLE

Added in 1.2.0
public static final int SHOW_PAGE_TITLE = 1

Shows the page title and the domain.

TOOLBAR_ACTION_BUTTON_ID

Added in 1.2.0
public static final int TOOLBAR_ACTION_BUTTON_ID = 0

The ID allocated to the custom action button that is shown on the toolbar.

Public fields

intent

Added in 1.2.0
public final @NonNull Intent intent

An Intent used to start the Custom Tabs Activity.

startAnimationBundle

Added in 1.2.0
public final @Nullable Bundle startAnimationBundle

A Bundle containing the start animation for the Custom Tabs Activity.

Public methods

getActivityResizeBehavior

Added in 1.5.0
public static int getActivityResizeBehavior(@NonNull Intent intent)

Gets the Custom Tab Activity's resize behavior.

Parameters
@NonNull Intent intent

Intent to retrieve the resize behavior from.

Returns
int

The resize behavior. If EXTRA_INITIAL_ACTIVITY_HEIGHT_PX is not set as part of the same intent, the value has no effect.

getActivitySideSheetBreakpointDp

Added in 1.8.0
public static @Dimension(unit = 0) int getActivitySideSheetBreakpointDp(@NonNull Intent intent)

Gets the breakpoint value in dp that will be used to decide if the Custom Tab will be displayed as a bottom sheet or as a side sheet.

Parameters
@NonNull Intent intent

Intent to retrieve the breakpoint value from.

Returns
@Dimension(unit = 0) int

The breakpoint value or 0 if it is not set.

getActivitySideSheetDecorationType

Added in 1.8.0
public static int getActivitySideSheetDecorationType(@NonNull Intent intent)

Gets the type of the decoration that will be used to separate the side sheet from the Custom Tabs embedder.

Parameters
@NonNull Intent intent

Intent to retrieve the decoration type from.

Returns
int

The position of the side sheet or the default value if it is not set.

getActivitySideSheetPosition

Added in 1.8.0
public static int getActivitySideSheetPosition(@NonNull Intent intent)

Gets the position where the side sheet should be displayed on the screen.

Parameters
@NonNull Intent intent

Intent to retrieve the side sheet position from.

Returns
int

The position of the side sheet or the default value if it is not set.

getActivitySideSheetRoundedCornersPosition

Added in 1.8.0
public static int getActivitySideSheetRoundedCornersPosition(@NonNull Intent intent)

Gets the type of rounded corners that will be used for the side sheet.

Parameters
@NonNull Intent intent

Intent to retrieve the decoration type from.

Returns
int

The position of the side sheet or the default value if it is not set.

getCloseButtonPosition

Added in 1.5.0
public static int getCloseButtonPosition(@NonNull Intent intent)

Gets the position of the close button.

Parameters
@NonNull Intent intent

Intent to retrieve the position of the close button from.

Returns
int

The position of the close button, or the default position if the extra is not set.

getColorSchemeParams

Added in 1.2.0
public static @NonNull CustomTabColorSchemeParams getColorSchemeParams(@NonNull Intent intent, int colorScheme)

Retrieves the instance of CustomTabColorSchemeParams from an Intent for a given color scheme. Uses values passed directly into CustomTabsIntent.Builder (e.g. via setToolbarColor) as defaults.

Parameters
@NonNull Intent intent

Intent to retrieve the color scheme parameters from.

int colorScheme

A constant representing a color scheme. Should not be COLOR_SCHEME_SYSTEM.

Returns
@NonNull CustomTabColorSchemeParams

An instance of CustomTabColorSchemeParams with retrieved parameters.

getInitialActivityHeightPx

Added in 1.5.0
public static @Dimension(unit = 1) int getInitialActivityHeightPx(@NonNull Intent intent)

Gets the Custom Tab Activity's initial height.

Parameters
@NonNull Intent intent

Intent to retrieve the initial Custom Tab Activity's height from.

Returns
@Dimension(unit = 1) int

The initial Custom Tab Activity's height or 0 if it is not set.

getInitialActivityWidthPx

Added in 1.8.0
public static @Dimension(unit = 1) int getInitialActivityWidthPx(@NonNull Intent intent)

Gets the Custom Tab Activity's initial width.

Parameters
@NonNull Intent intent

Intent to retrieve the initial Custom Tab Activity's width from.

Returns
@Dimension(unit = 1) int

The initial Custom Tab Activity's width or 0 if it is not set.

getMaxToolbarItems

Added in 1.2.0
public static int getMaxToolbarItems()
Returns
int

The maximum number of allowed toolbar items for addToolbarItem and EXTRA_TOOLBAR_ITEMS.

getSecondaryToolbarSwipeUpGesture

Added in 1.7.0
public static @Nullable PendingIntent getSecondaryToolbarSwipeUpGesture(@NonNull Intent intent)
Returns
@Nullable PendingIntent

The PendingIntent that will be sent when the user swipes up from the secondary toolbar.

getToolbarCornerRadiusDp

Added in 1.5.0
public static @Dimension(unit = 0) int getToolbarCornerRadiusDp(@NonNull Intent intent)

Gets the toolbar's top corner radii in dp.

Parameters
@NonNull Intent intent

Intent to retrieve the toolbar's top corner radii from.

Returns
@Dimension(unit = 0) int

The toolbar's top corner radii in dp.

getTranslateLocale

Added in 1.7.0
public static @Nullable Locale getTranslateLocale(@NonNull Intent intent)

Gets the target locale for the Translate UI.

Returns
@Nullable Locale

The target locale the Translate UI should be triggered with.

isActivitySideSheetMaximizationEnabled

Added in 1.8.0
public static boolean isActivitySideSheetMaximizationEnabled(@NonNull Intent intent)

Whether the Custom Tab Activity, when acting as a side sheet, can be maximized.

isBackgroundInteractionEnabled

Added in 1.7.0
public static boolean isBackgroundInteractionEnabled(@NonNull Intent intent)
Returns
boolean

Whether the background interaction is enabled.

isBookmarksButtonEnabled

Added in 1.7.0
public static boolean isBookmarksButtonEnabled(@NonNull Intent intent)
Returns
boolean

Whether the bookmarks button is enabled.

isDownloadButtonEnabled

Added in 1.7.0
public static boolean isDownloadButtonEnabled(@NonNull Intent intent)
Returns
boolean

Whether the download button is enabled.

isSendToExternalDefaultHandlerEnabled

Added in 1.7.0
public static boolean isSendToExternalDefaultHandlerEnabled(@NonNull Intent intent)
Returns
boolean

Whether initial urls are to be sent to external handler apps.

launchUrl

Added in 1.2.0
public void launchUrl(@NonNull Context context, @NonNull Uri url)

Convenience method to launch a Custom Tabs Activity.

Parameters
@NonNull Context context

The source Context.

@NonNull Uri url

The URL to load in the Custom Tab.

setAlwaysUseBrowserUI

Added in 1.2.0
public static @NonNull Intent setAlwaysUseBrowserUI(@Nullable Intent intent)

Adds the necessary flags and extras to signal any browser supporting custom tabs to use the browser UI at all times and avoid showing custom tab like UI. Calling this with an intent will override any custom tabs related customizations.

Parameters
@Nullable Intent intent

The intent to modify for always showing browser UI.

Returns
@NonNull Intent

The same intent with the necessary flags and extras added.

shouldAlwaysUseBrowserUI

Added in 1.2.0
public static boolean shouldAlwaysUseBrowserUI(@NonNull Intent intent)

Whether a browser receiving the given intent should always use browser UI and avoid using any custom tabs UI.

Parameters
@NonNull Intent intent

The intent to check for the required flags and extras.

Returns
boolean

Whether the browser UI should be used exclusively.