CustomTabsIntent

class CustomTabsIntent
kotlin.Any
   ↳ androidx.browser.customtabs.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 classes

Builder class for CustomTabsIntent objects.

Constants
static String

Extra used to match the session.

static String

Extra that changes the background color for the toolbar.

static String

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

static String

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

static String

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

static Int

Don't show any title.

static Int

Shows the page title and the domain.

static String

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

static String

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

static String

Extra that changes the background color for the secondary toolbar.

static String

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

static String

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

static String

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

static String

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

static String

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

static String

Key for specifying the title of a menu item.

static String

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

static String

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

static String

Extra that specifies the RemoteViews showing on the secondary toolbar.

static String

Extra that specifies an array of View ids.

static String

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

static String

Extra that specifies which View has been clicked.

static String

Extra that specifies whether Instant Apps is enabled.

static String

Key that specifies the unique ID for an action button.

static Int

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

Public methods
Unit
launchUrl(context: Context!, url: Uri!)

Convenience method to launch a Custom Tabs Activity.

static Int

static 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.

Properties
Intent!

An Intent used to start the Custom Tabs Activity.

Bundle!

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

Constants

EXTRA_SESSION

static val EXTRA_SESSION: String

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.

Value: "android.support.customtabs.extra.SESSION"

EXTRA_TOOLBAR_COLOR

static val EXTRA_TOOLBAR_COLOR: String

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

Value: "android.support.customtabs.extra.TOOLBAR_COLOR"

EXTRA_ENABLE_URLBAR_HIDING

static val EXTRA_ENABLE_URLBAR_HIDING: String

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

Value: "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"

EXTRA_CLOSE_BUTTON_ICON

static val EXTRA_CLOSE_BUTTON_ICON: String

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.

Value: "android.support.customtabs.extra.CLOSE_BUTTON_ICON"

EXTRA_TITLE_VISIBILITY_STATE

static val EXTRA_TITLE_VISIBILITY_STATE: String

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

Value: "android.support.customtabs.extra.TITLE_VISIBILITY"

NO_TITLE

static val NO_TITLE: Int

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

Value: 0

SHOW_PAGE_TITLE

static val SHOW_PAGE_TITLE: Int

Shows the page title and the domain.

Value: 1

EXTRA_ACTION_BUTTON_BUNDLE

static val EXTRA_ACTION_BUTTON_BUNDLE: String

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.

Value: "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"

EXTRA_TOOLBAR_ITEMS

static val EXTRA_TOOLBAR_ITEMS: String

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

Value: "android.support.customtabs.extra.TOOLBAR_ITEMS"

EXTRA_SECONDARY_TOOLBAR_COLOR

static val EXTRA_SECONDARY_TOOLBAR_COLOR: String

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

Value: "android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR"

KEY_ICON

static val KEY_ICON: String

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.

Value: "android.support.customtabs.customaction.ICON"

KEY_DESCRIPTION

static val KEY_DESCRIPTION: String

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

Value: "android.support.customtabs.customaction.DESCRIPTION"

KEY_PENDING_INTENT

static val KEY_PENDING_INTENT: String

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

Value: "android.support.customtabs.customaction.PENDING_INTENT"

EXTRA_TINT_ACTION_BUTTON

static val EXTRA_TINT_ACTION_BUTTON: String

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

Value: "android.support.customtabs.extra.TINT_ACTION_BUTTON"

EXTRA_MENU_ITEMS

static val EXTRA_MENU_ITEMS: String

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

Value: "android.support.customtabs.extra.MENU_ITEMS"

KEY_MENU_ITEM_TITLE

static val KEY_MENU_ITEM_TITLE: String

Key for specifying the title of a menu item.

Value: "android.support.customtabs.customaction.MENU_ITEM_TITLE"

EXTRA_EXIT_ANIMATION_BUNDLE

static val EXTRA_EXIT_ANIMATION_BUNDLE: String

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.

Value: "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"

EXTRA_DEFAULT_SHARE_MENU_ITEM

static val EXTRA_DEFAULT_SHARE_MENU_ITEM: String

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

Value: "android.support.customtabs.extra.SHARE_MENU_ITEM"

EXTRA_REMOTEVIEWS

static val EXTRA_REMOTEVIEWS: String

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.

Value: "android.support.customtabs.extra.EXTRA_REMOTEVIEWS"

EXTRA_REMOTEVIEWS_VIEW_IDS

static val EXTRA_REMOTEVIEWS_VIEW_IDS: String

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 RemoteViews#setOnClickPendingIntent(int, PendingIntent) instead.

Value: "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_VIEW_IDS"

EXTRA_REMOTEVIEWS_PENDINGINTENT

static val EXTRA_REMOTEVIEWS_PENDINGINTENT: String

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.

Value: "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT"

EXTRA_REMOTEVIEWS_CLICKED_ID

static val EXTRA_REMOTEVIEWS_CLICKED_ID: String

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

Value: "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID"

EXTRA_ENABLE_INSTANT_APPS

static val EXTRA_ENABLE_INSTANT_APPS: String

Extra that specifies whether Instant Apps is enabled.

Value: "android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS"

KEY_ID

static val KEY_ID: String

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.

Value: "android.support.customtabs.customaction.ID"

TOOLBAR_ACTION_BUTTON_ID

static val TOOLBAR_ACTION_BUTTON_ID: Int

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

Value: 0

Public methods

launchUrl

fun launchUrl(context: Context!, url: Uri!): Unit

Convenience method to launch a Custom Tabs Activity.

Parameters
context Context!: The source Context.
url Context!: The URL to load in the Custom Tab.

getMaxToolbarItems

static fun getMaxToolbarItems(): Int
Return
Int: The maximum number of allowed toolbar items for CustomTabsIntent.Builder#addToolbarItem(int, Bitmap, String, PendingIntent) and CustomTabsIntent#EXTRA_TOOLBAR_ITEMS.

setAlwaysUseBrowserUI

static fun setAlwaysUseBrowserUI(intent: 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
intent Intent!: The intent to modify for always showing browser UI.
Return
Intent!: The same intent with the necessary flags and extras added.

shouldAlwaysUseBrowserUI

static fun shouldAlwaysUseBrowserUI(intent: Intent!): Boolean

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

Parameters
intent Intent!: The intent to check for the required flags and extras.
Return
Boolean: Whether the browser UI should be used exclusively.

Properties

intent

@NonNull val intent: Intent!

An Intent used to start the Custom Tabs Activity.

startAnimationBundle

@Nullable val startAnimationBundle: Bundle!

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