public final class CustomTabsIntent extends Object
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
.
Modifier and Type | Class and Description |
---|---|
static class |
CustomTabsIntent.Builder
Builder class for
CustomTabsIntent objects. |
Modifier and Type | Field and Description |
---|---|
static String |
EXTRA_ACTION_BUTTON_BUNDLE
Bundle used for adding a custom action button to the custom tab toolbar.
|
static String |
EXTRA_CLOSE_BUTTON_ICON
Extra bitmap that specifies the icon of the back button on the toolbar.
|
static String |
EXTRA_DEFAULT_SHARE_MENU_ITEM
Boolean extra that specifies whether a default share button will be shown in the menu.
|
static String |
EXTRA_ENABLE_INSTANT_APPS
Extra that specifies whether Instant Apps is enabled.
|
static String |
EXTRA_ENABLE_URLBAR_HIDING
Boolean extra that enables the url bar to hide as the user scrolls down the page
|
static String |
EXTRA_EXIT_ANIMATION_BUNDLE
Bundle constructed out of
ActivityOptionsCompat that will be running when the
Activity that holds the custom tab gets finished. |
static String |
EXTRA_MENU_ITEMS
Use an
ArrayList<Bundle> for specifying menu related params. |
static String |
EXTRA_REMOTEVIEWS
Extra that specifies the
RemoteViews showing on the secondary toolbar. |
static String |
EXTRA_REMOTEVIEWS_CLICKED_ID
Extra that specifies which
View has been clicked. |
static String |
EXTRA_REMOTEVIEWS_PENDINGINTENT
Extra that specifies the
PendingIntent to be sent when the user clicks on the
View s that is listed by EXTRA_REMOTEVIEWS_VIEW_IDS . |
static String |
EXTRA_REMOTEVIEWS_VIEW_IDS
Extra that specifies an array of
View ids. |
static String |
EXTRA_SECONDARY_TOOLBAR_COLOR
Extra that changes the background color for the secondary toolbar.
|
static String |
EXTRA_SESSION
Extra used to match the session.
|
static String |
EXTRA_TINT_ACTION_BUTTON
Extra boolean that specifies whether the custom action button should be tinted.
|
static String |
EXTRA_TITLE_VISIBILITY_STATE
Extra (int) that specifies state for showing the page title.
|
static String |
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 String |
EXTRA_TOOLBAR_ITEMS
List
|
Intent |
intent
An
Intent used to start the Custom Tabs Activity. |
static String |
KEY_DESCRIPTION
Key that specifies the content description for the custom action button.
|
static String |
KEY_ICON
Key that specifies the
Bitmap to be used as the image source for the action button. |
static String |
KEY_ID
Key that specifies the unique ID for an action button.
|
static String |
KEY_MENU_ITEM_TITLE
Key for specifying the title of a menu item.
|
static String |
KEY_PENDING_INTENT
Key that specifies the PendingIntent to launch when the action button or menu item was
clicked.
|
static int |
NO_TITLE
Don't show any title.
|
static int |
SHOW_PAGE_TITLE
Shows the page title and the domain.
|
Bundle |
startAnimationBundle
A
Bundle containing the start animation for the Custom Tabs Activity. |
static int |
TOOLBAR_ACTION_BUTTON_ID
The ID allocated to the custom action button that is shown on the toolbar.
|
Modifier and Type | Method and Description |
---|---|
static int |
getMaxToolbarItems() |
void |
launchUrl(Context context,
Uri url)
Convenience method to launch a Custom Tabs Activity.
|
static Intent |
setAlwaysUseBrowserUI(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.
|
static boolean |
shouldAlwaysUseBrowserUI(Intent intent)
Whether a browser receiving the given intent should always use browser UI and avoid using any
custom tabs UI.
|
public static final String EXTRA_SESSION
public static final String EXTRA_TOOLBAR_COLOR
Color
, not a resource id.public static final String EXTRA_ENABLE_URLBAR_HIDING
public static final String EXTRA_CLOSE_BUTTON_ICON
public static final String EXTRA_TITLE_VISIBILITY_STATE
NO_TITLE
.public static final int NO_TITLE
public static final int SHOW_PAGE_TITLE
public static final String EXTRA_ACTION_BUTTON_BUNDLE
Bitmap
and a PendingIntent
for the button.
All three keys must be present.public static final String EXTRA_TOOLBAR_ITEMS
Bitmap
for each item. They may also provide a
PendingIntent
if the item is a button.public static final String EXTRA_SECONDARY_TOOLBAR_COLOR
Color
, not a resource id.public static final String KEY_ICON
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.public static final String KEY_DESCRIPTION
public static final String KEY_PENDING_INTENT
PendingIntent.send()
on clicks after adding
the url as data. The client app can call Intent.getDataString()
to get the url.public static final String EXTRA_TINT_ACTION_BUTTON
public static final String EXTRA_MENU_ITEMS
ArrayList<Bundle>
for specifying menu related params. There should be a
separate Bundle
for each custom menu item.public static final String KEY_MENU_ITEM_TITLE
public static final String EXTRA_EXIT_ANIMATION_BUNDLE
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.public static final String EXTRA_DEFAULT_SHARE_MENU_ITEM
public static final String EXTRA_REMOTEVIEWS
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.public static final String EXTRA_REMOTEVIEWS_VIEW_IDS
View
ids. When these View
s 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 View
s.
If you do not care about the current url, you can safely ignore this extra and use
RemoteViews.setOnClickPendingIntent(int, PendingIntent)
instead.
public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT
PendingIntent
to be sent when the user clicks on the
View
s 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
.
public static final String EXTRA_REMOTEVIEWS_CLICKED_ID
View
has been clicked. This extra will be put to the
PendingIntent
sent from Custom Tabs when a view in the RemoteViews
is clickedpublic static final String EXTRA_ENABLE_INSTANT_APPS
public static final String KEY_ID
TOOLBAR_ACTION_BUTTON_ID
as its ID.public static final int TOOLBAR_ACTION_BUTTON_ID
public void launchUrl(Context context, Uri url)
context
- The source Context.url
- The URL to load in the Custom Tab.public static int getMaxToolbarItems()
CustomTabsIntent.Builder.addToolbarItem(int, Bitmap, String, PendingIntent)
and
EXTRA_TOOLBAR_ITEMS
.public static Intent setAlwaysUseBrowserUI(Intent intent)
intent
- The intent to modify for always showing browser UI.public static boolean shouldAlwaysUseBrowserUI(Intent intent)
intent
- The intent to check for the required flags and extras.