public static final class CustomTabsIntent.Builder extends Object
CustomTabsIntent
objects.Constructor and Description |
---|
Builder()
Creates a
CustomTabsIntent.Builder object associated with no
CustomTabsSession . |
Builder(CustomTabsSession session)
Creates a
CustomTabsIntent.Builder object associated with a given
CustomTabsSession . |
Modifier and Type | Method and Description |
---|---|
CustomTabsIntent.Builder |
addDefaultShareMenuItem()
Adds a default share item to the menu.
|
CustomTabsIntent.Builder |
addMenuItem(String label,
PendingIntent pendingIntent)
Adds a menu item.
|
CustomTabsIntent.Builder |
addToolbarItem(int id,
Bitmap icon,
String description,
PendingIntent pendingIntent)
Deprecated.
Use
CustomTabsIntent.Builder#setSecondaryToolbarViews(RemoteViews, int[], PendingIntent).
|
CustomTabsIntent |
build()
Combines all the options that have been set and returns a new
CustomTabsIntent
object. |
CustomTabsIntent.Builder |
enableUrlBarHiding()
Enables the url bar to hide as the user scrolls down on the page.
|
CustomTabsIntent.Builder |
setActionButton(Bitmap icon,
String description,
PendingIntent pendingIntent)
Sets the action button that is displayed in the Toolbar with default tinting behavior.
|
CustomTabsIntent.Builder |
setActionButton(Bitmap icon,
String description,
PendingIntent pendingIntent,
boolean shouldTint)
Sets the action button that is displayed in the Toolbar.
|
CustomTabsIntent.Builder |
setCloseButtonIcon(Bitmap icon)
Sets the Close button icon for the custom tab.
|
CustomTabsIntent.Builder |
setExitAnimations(Context context,
int enterResId,
int exitResId)
Sets the exit animations.
|
CustomTabsIntent.Builder |
setInstantAppsEnabled(boolean enabled)
Sets whether Instant Apps is enabled for this Custom Tab.
|
CustomTabsIntent.Builder |
setSecondaryToolbarColor(int color)
Sets the color of the secondary toolbar.
|
CustomTabsIntent.Builder |
setSecondaryToolbarViews(RemoteViews remoteViews,
int[] clickableIDs,
PendingIntent pendingIntent)
Sets the remote views displayed in the secondary toolbar in a custom tab.
|
CustomTabsIntent.Builder |
setShowTitle(boolean showTitle)
Sets whether the title should be shown in the custom tab.
|
CustomTabsIntent.Builder |
setStartAnimations(Context context,
int enterResId,
int exitResId)
Sets the start animations.
|
CustomTabsIntent.Builder |
setToolbarColor(int color)
Sets the toolbar color.
|
public Builder()
CustomTabsIntent.Builder
object associated with no
CustomTabsSession
.public Builder(@Nullable CustomTabsSession session)
CustomTabsIntent.Builder
object associated with a given
CustomTabsSession
.
Guarantees that the Intent
will be sent to the same component as the one the
session is associated with.session
- The session to associate this Builder with.public CustomTabsIntent.Builder setToolbarColor(int color)
color
- Color
public CustomTabsIntent.Builder enableUrlBarHiding()
public CustomTabsIntent.Builder setCloseButtonIcon(@NonNull Bitmap icon)
icon
- The icon Bitmap
public CustomTabsIntent.Builder setShowTitle(boolean showTitle)
showTitle
- Whether the title should be shown.public CustomTabsIntent.Builder addMenuItem(@NonNull String label, @NonNull PendingIntent pendingIntent)
label
- Menu label.pendingIntent
- Pending intent delivered when the menu item is clicked.public CustomTabsIntent.Builder addDefaultShareMenuItem()
public CustomTabsIntent.Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, @NonNull PendingIntent pendingIntent, boolean shouldTint)
This is equivalent to calling
addToolbarItem(int, Bitmap, String, PendingIntent)
with CustomTabsIntent.TOOLBAR_ACTION_BUTTON_ID
as id.
icon
- The icon.description
- The description for the button. To be used for accessibility.pendingIntent
- pending intent delivered when the button is clicked.shouldTint
- Whether the action button should be tinted.addToolbarItem(int, Bitmap, String, PendingIntent)
public CustomTabsIntent.Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, @NonNull PendingIntent pendingIntent)
CustomTabsIntent.Builder#setActionButton(
Bitmap, String, PendingIntent, boolean)}
@Deprecated public CustomTabsIntent.Builder addToolbarItem(int id, @NonNull Bitmap icon, @NonNull String description, PendingIntent pendingIntent) throws IllegalStateException
CustomTabsIntent.TOOLBAR_ACTION_BUTTON_ID
, the button will be placed on
the toolbar; if the bitmap is too wide, it will be put to the bottom bar instead. If
the id is not CustomTabsIntent.TOOLBAR_ACTION_BUTTON_ID
, it will be directly put on secondary
toolbar. The maximum number of allowed toolbar items in a single intent is
CustomTabsIntent.getMaxToolbarItems()
. Throws an
IllegalStateException
when that number is exceeded per intent.id
- The unique id of the action button. This should be non-negative.icon
- The icon.description
- The description for the button. To be used for accessibility.pendingIntent
- The pending intent delivered when the button is clicked.IllegalStateException
CustomTabsIntent.getMaxToolbarItems()
public CustomTabsIntent.Builder setSecondaryToolbarColor(int color)
color
- The color for the secondary toolbar.public CustomTabsIntent.Builder setSecondaryToolbarViews(@NonNull RemoteViews remoteViews, @Nullable int[] clickableIDs, @Nullable PendingIntent pendingIntent)
remoteViews
- The RemoteViews
that will be shown on the secondary toolbar.clickableIDs
- The IDs of clickable views. The onClick event of these views will be
handled by custom tabs.pendingIntent
- The PendingIntent
that will be sent when the user clicks on
one of the View
s in clickableIDs. When the
PendingIntent
is sent, it will have the current URL as its
intent data.CustomTabsIntent.EXTRA_REMOTEVIEWS
,
CustomTabsIntent.EXTRA_REMOTEVIEWS_VIEW_IDS
,
CustomTabsIntent.EXTRA_REMOTEVIEWS_PENDINGINTENT
,
CustomTabsIntent.EXTRA_REMOTEVIEWS_CLICKED_ID
public CustomTabsIntent.Builder setInstantAppsEnabled(boolean enabled)
enabled
- Whether Instant Apps should be enabled.public CustomTabsIntent.Builder setStartAnimations(@NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId)
context
- Application context.enterResId
- Resource ID of the "enter" animation for the browser.exitResId
- Resource ID of the "exit" animation for the application.public CustomTabsIntent.Builder setExitAnimations(@NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId)
context
- Application context.enterResId
- Resource ID of the "enter" animation for the application.exitResId
- Resource ID of the "exit" animation for the browser.public CustomTabsIntent build()
CustomTabsIntent
object.