Most visited

Recently visited

CustomTabsIntent.Builder

public static final class CustomTabsIntent.Builder
extends Object

java.lang.Object
   ↳ android.support.customtabs.CustomTabsIntent.Builder


Builder class for CustomTabsIntent objects.

Summary

Public constructors

CustomTabsIntent.Builder()

Creates a CustomTabsIntent.Builder object associated with no CustomTabsSession.

CustomTabsIntent.Builder(CustomTabsSession session)

Creates a CustomTabsIntent.Builder object associated with a given CustomTabsSession.

Public methods

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)

This method is 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, boolean shouldTint)

Sets the action button that is displayed in the Toolbar.

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

Inherited methods

From class java.lang.Object

Public constructors

CustomTabsIntent.Builder

CustomTabsIntent.Builder ()

Creates a CustomTabsIntent.Builder object associated with no CustomTabsSession.

CustomTabsIntent.Builder

CustomTabsIntent.Builder (CustomTabsSession session)

Creates a 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.

Parameters
session CustomTabsSession: The session to associate this Builder with.

Public methods

addDefaultShareMenuItem

CustomTabsIntent.Builder addDefaultShareMenuItem ()

Adds a default share item to the menu.

Returns
CustomTabsIntent.Builder

addMenuItem

CustomTabsIntent.Builder addMenuItem (String label, 
                PendingIntent pendingIntent)

Adds a menu item.

Parameters
label String: Menu label.
pendingIntent PendingIntent: Pending intent delivered when the menu item is clicked.
Returns
CustomTabsIntent.Builder

addToolbarItem

CustomTabsIntent.Builder addToolbarItem (int id, 
                Bitmap icon, 
                String description, 
                PendingIntent pendingIntent)

This method is deprecated.
Use CustomTabsIntent.Builder#setSecondaryToolbarViews(RemoteViews, int[], PendingIntent).

Adds an action button to the custom tab. Multiple buttons can be added via this method. If the given id equals 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 TOOLBAR_ACTION_BUTTON_ID, it will be directly put on secondary toolbar. The maximum number of allowed toolbar items in a single intent is getMaxToolbarItems(). Throws an IllegalStateException when that number is exceeded per intent.

Parameters
id int: The unique id of the action button. This should be non-negative.
icon Bitmap: The icon.
description String: The description for the button. To be used for accessibility.
pendingIntent PendingIntent: The pending intent delivered when the button is clicked.
Returns
CustomTabsIntent.Builder
Throws
IllegalStateException

See also:

build

CustomTabsIntent build ()

Combines all the options that have been set and returns a new CustomTabsIntent object.

Returns
CustomTabsIntent

enableUrlBarHiding

CustomTabsIntent.Builder enableUrlBarHiding ()

Enables the url bar to hide as the user scrolls down on the page.

Returns
CustomTabsIntent.Builder

setActionButton

CustomTabsIntent.Builder setActionButton (Bitmap icon, 
                String description, 
                PendingIntent pendingIntent, 
                boolean shouldTint)

Sets the action button that is displayed in the Toolbar.

This is equivalent to calling addToolbarItem(int, Bitmap, String, PendingIntent) with TOOLBAR_ACTION_BUTTON_ID as id.

Parameters
icon Bitmap: The icon.
description String: The description for the button. To be used for accessibility.
pendingIntent PendingIntent: pending intent delivered when the button is clicked.
shouldTint boolean: Whether the action button should be tinted.
Returns
CustomTabsIntent.Builder

See also:

setActionButton

CustomTabsIntent.Builder setActionButton (Bitmap icon, 
                String description, 
                PendingIntent pendingIntent)

Sets the action button that is displayed in the Toolbar with default tinting behavior.

Parameters
icon Bitmap
description String
pendingIntent PendingIntent
Returns
CustomTabsIntent.Builder

See also:

setCloseButtonIcon

CustomTabsIntent.Builder setCloseButtonIcon (Bitmap icon)

Sets the Close button icon for the custom tab.

Parameters
icon Bitmap: The icon Bitmap
Returns
CustomTabsIntent.Builder

setExitAnimations

CustomTabsIntent.Builder setExitAnimations (Context context, 
                int enterResId, 
                int exitResId)

Sets the exit animations.

Parameters
context Context: Application context.
enterResId int: Resource ID of the "enter" animation for the application.
exitResId int: Resource ID of the "exit" animation for the browser.
Returns
CustomTabsIntent.Builder

setSecondaryToolbarColor

CustomTabsIntent.Builder setSecondaryToolbarColor (int color)

Sets the color of the secondary toolbar.

Parameters
color int: The color for the secondary toolbar.
Returns
CustomTabsIntent.Builder

setSecondaryToolbarViews

CustomTabsIntent.Builder setSecondaryToolbarViews (RemoteViews remoteViews, 
                int[] clickableIDs, 
                PendingIntent pendingIntent)

Sets the remote views displayed in the secondary toolbar in a custom tab.

Parameters
remoteViews RemoteViews: The RemoteViews that will be shown on the secondary toolbar.
clickableIDs int: The IDs of clickable views. The onClick event of these views will be handled by custom tabs.
pendingIntent PendingIntent: The PendingIntent that will be sent when the user clicks on one of the Views in clickableIDs. When the PendingIntent is sent, it will have the current URL as its intent data.
Returns
CustomTabsIntent.Builder

See also:

setShowTitle

CustomTabsIntent.Builder setShowTitle (boolean showTitle)

Sets whether the title should be shown in the custom tab.

Parameters
showTitle boolean: Whether the title should be shown.
Returns
CustomTabsIntent.Builder

setStartAnimations

CustomTabsIntent.Builder setStartAnimations (Context context, 
                int enterResId, 
                int exitResId)

Sets the start animations.

Parameters
context Context: Application context.
enterResId int: Resource ID of the "enter" animation for the browser.
exitResId int: Resource ID of the "exit" animation for the application.
Returns
CustomTabsIntent.Builder

setToolbarColor

CustomTabsIntent.Builder setToolbarColor (int color)

Sets the toolbar color.

Parameters
color int: Color
Returns
CustomTabsIntent.Builder

Hooray!