TrustedWebActivityIntentBuilder


class TrustedWebActivityIntentBuilder


Constructs instances of TrustedWebActivityIntent that can be used to start Trusted Web Activities (see TrustedWebUtils for more details).

Summary

Constants

const String!
EXTRA_ADDITIONAL_TRUSTED_ORIGINS = "android.support.customtabs.extra.ADDITIONAL_TRUSTED_ORIGINS"

Extra for the Trusted Web Activity launch Intent to specify a list of origins for the browser to treat as trusted, in addition to the origin of the launching URL.

const String!
EXTRA_DISPLAY_MODE = "androidx.browser.trusted.extra.DISPLAY_MODE"

Extra for the TrustedWebActivityDisplayMode, see setDisplayMode.

const String!
EXTRA_SCREEN_ORIENTATION = "androidx.browser.trusted.extra.SCREEN_ORIENTATION"

Extra for the screenOrientation, see setScreenOrientation.

const String!
EXTRA_SHARE_DATA = "androidx.browser.trusted.extra.SHARE_DATA"

Extra for the share data, see setShareParams.

const String!
EXTRA_SHARE_TARGET = "androidx.browser.trusted.extra.SHARE_TARGET"

Extra for the share target, see setShareParams.

const String!
EXTRA_SPLASH_SCREEN_PARAMS = "androidx.browser.trusted.EXTRA_SPLASH_SCREEN_PARAMS"

Extra for the Trusted Web Activity launch Intent to specify a Bundle of parameters for the browser to use in constructing a splash screen.

Public constructors

Creates a Builder given the required parameters.

Public functions

TrustedWebActivityIntent

Builds an instance of TrustedWebActivityIntent.

CustomTabsIntent

Builds a CustomTabsIntent based on provided parameters.

TrustedWebActivityDisplayMode

Returns TrustedWebActivityDisplayMode set on this Builder.

Uri

Returns the Uri to be launched with this Builder.

TrustedWebActivityIntentBuilder

Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri.

TrustedWebActivityIntentBuilder
setColorScheme(colorScheme: Int)

Sets the color scheme, see setColorScheme.

TrustedWebActivityIntentBuilder
setColorSchemeParams(
    colorScheme: Int,
    params: CustomTabColorSchemeParams
)

Sets CustomTabColorSchemeParams for the given color scheme.

TrustedWebActivityIntentBuilder

Sets the default CustomTabColorSchemeParams.

TrustedWebActivityIntentBuilder

Sets a TrustedWebActivityDisplayMode.

TrustedWebActivityIntentBuilder

This function is deprecated.

Use setDefaultColorSchemeParams instead.

TrustedWebActivityIntentBuilder

This function is deprecated.

Use setDefaultColorSchemeParams instead.

TrustedWebActivityIntentBuilder
setScreenOrientation(orientation: Int)

Sets a screenOrientation.

TrustedWebActivityIntentBuilder
setShareParams(shareTarget: ShareTarget, shareData: ShareData)

Sets the parameters for delivering data to a Web Share Target via a Trusted Web Activity.

TrustedWebActivityIntentBuilder
setSplashScreenParams(splashScreenParams: Bundle)

Sets the parameters of a splash screen shown while the web page is loading, such as background color.

TrustedWebActivityIntentBuilder

This function is deprecated.

Use setDefaultColorSchemeParams instead.

Constants

EXTRA_ADDITIONAL_TRUSTED_ORIGINS

Added in 1.2.0
const val EXTRA_ADDITIONAL_TRUSTED_ORIGINS = "android.support.customtabs.extra.ADDITIONAL_TRUSTED_ORIGINS": String!

Extra for the Trusted Web Activity launch Intent to specify a list of origins for the browser to treat as trusted, in addition to the origin of the launching URL. It is recommended to use TrustedWebActivityIntentBuilder instead of manually piecing the Intent together.

EXTRA_DISPLAY_MODE

Added in 1.2.0
const val EXTRA_DISPLAY_MODE = "androidx.browser.trusted.extra.DISPLAY_MODE": String!

Extra for the TrustedWebActivityDisplayMode, see setDisplayMode.

EXTRA_SCREEN_ORIENTATION

Added in 1.3.0
const val EXTRA_SCREEN_ORIENTATION = "androidx.browser.trusted.extra.SCREEN_ORIENTATION": String!

Extra for the screenOrientation, see setScreenOrientation.

EXTRA_SHARE_DATA

Added in 1.2.0
const val EXTRA_SHARE_DATA = "androidx.browser.trusted.extra.SHARE_DATA": String!

Extra for the share data, see setShareParams.

EXTRA_SHARE_TARGET

Added in 1.2.0
const val EXTRA_SHARE_TARGET = "androidx.browser.trusted.extra.SHARE_TARGET": String!

Extra for the share target, see setShareParams.

EXTRA_SPLASH_SCREEN_PARAMS

Added in 1.2.0
const val EXTRA_SPLASH_SCREEN_PARAMS = "androidx.browser.trusted.EXTRA_SPLASH_SCREEN_PARAMS": String!

Extra for the Trusted Web Activity launch Intent to specify a Bundle of parameters for the browser to use in constructing a splash screen. It is recommended to use TrustedWebActivityIntentBuilder instead of manually piecing the Intent together.

Public constructors

TrustedWebActivityIntentBuilder

Added in 1.2.0
TrustedWebActivityIntentBuilder(uri: Uri)

Creates a Builder given the required parameters.

Parameters
uri: Uri

The web page to launch as Trusted Web Activity.

Public functions

build

Added in 1.2.0
fun build(session: CustomTabsSession): TrustedWebActivityIntent

Builds an instance of TrustedWebActivityIntent.

Parameters
session: CustomTabsSession

The CustomTabsSession to use for launching a Trusted Web Activity.

buildCustomTabsIntent

Added in 1.2.0
fun buildCustomTabsIntent(): CustomTabsIntent

Builds a CustomTabsIntent based on provided parameters. Can be useful for falling back to Custom Tabs when Trusted Web Activity providers are unavailable.

getDisplayMode

Added in 1.2.0
fun getDisplayMode(): TrustedWebActivityDisplayMode

Returns TrustedWebActivityDisplayMode set on this Builder.

getUri

Added in 1.2.0
fun getUri(): Uri

Returns the Uri to be launched with this Builder.

setAdditionalTrustedOrigins

Added in 1.2.0
fun setAdditionalTrustedOrigins(origins: (Mutable)List<String!>): TrustedWebActivityIntentBuilder

Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri. For example, if the user starts at https://www.example.com/page1 and is redirected to https://m.example.com/page2, and both origins are associated with the calling application via the Digital Asset Links, then pass "https://www.example.com/page1" as uri and Arrays.asList("https://m.example.com") as additionalTrustedOrigins. Alternatively, use validateRelationship to validate additional origins asynchronously, but that would delay launching the Trusted Web Activity.

setColorScheme

Added in 1.2.0
fun setColorScheme(colorScheme: Int): TrustedWebActivityIntentBuilder

Sets the color scheme, see setColorScheme. In Trusted Web Activities color scheme may affect such UI elements as info bars and context menus.

Parameters
colorScheme: Int

Must be one of COLOR_SCHEME_SYSTEM, COLOR_SCHEME_LIGHT, and COLOR_SCHEME_DARK.

setColorSchemeParams

Added in 1.2.0
fun setColorSchemeParams(
    colorScheme: Int,
    params: CustomTabColorSchemeParams
): TrustedWebActivityIntentBuilder

Sets CustomTabColorSchemeParams for the given color scheme. This allows, for example, to set two navigation bar colors - for light and dark scheme. Trusted Web Activity will automatically apply the correct color according to current system settings. For more details see setColorSchemeParams.

setDefaultColorSchemeParams

Added in 1.3.0
fun setDefaultColorSchemeParams(params: CustomTabColorSchemeParams): TrustedWebActivityIntentBuilder

Sets the default CustomTabColorSchemeParams. This will set a default color scheme that applies when no CustomTabColorSchemeParams specified for current color scheme via setColorSchemeParams.

Parameters
params: CustomTabColorSchemeParams

An instance of CustomTabColorSchemeParams.

setDisplayMode

Added in 1.2.0
fun setDisplayMode(displayMode: TrustedWebActivityDisplayMode): TrustedWebActivityIntentBuilder

Sets a TrustedWebActivityDisplayMode. This can be used e.g. to enable immersive mode (see TrustedWebActivityDisplayMode.ImmersiveMode. Not setting it means TrustedWebActivityDisplayMode.DefaultMode will be used.

setNavigationBarColor

Added in 1.2.0
Deprecated in 1.3.0
fun setNavigationBarColor(color: @ColorInt Int): TrustedWebActivityIntentBuilder

Sets the navigation bar color, see setNavigationBarColor.

setNavigationBarDividerColor

Added in 1.3.0
Deprecated in 1.3.0
fun setNavigationBarDividerColor(color: @ColorInt Int): TrustedWebActivityIntentBuilder

Sets the navigation bar divider color, see setNavigationBarDividerColor.

setScreenOrientation

Added in 1.3.0
fun setScreenOrientation(orientation: Int): TrustedWebActivityIntentBuilder

Sets a screenOrientation. This can be used e.g. to enable the locking of an orientation lock type ScreenOrientation.

Parameters
orientation: Int

A ScreenOrientation lock type for a Trusted Web Activity. Not setting it means DEFAULT will be used.

setShareParams

Added in 1.2.0
fun setShareParams(shareTarget: ShareTarget, shareData: ShareData): TrustedWebActivityIntentBuilder

Sets the parameters for delivering data to a Web Share Target via a Trusted Web Activity.

Parameters
shareTarget: ShareTarget

A ShareTarget object describing the Web Share Target.

shareData: ShareData

A ShareData object containing the data to be sent to the Web Share Target.

setSplashScreenParams

Added in 1.2.0
fun setSplashScreenParams(splashScreenParams: Bundle): TrustedWebActivityIntentBuilder

Sets the parameters of a splash screen shown while the web page is loading, such as background color. See SplashScreenParamKey for a list of supported parameters. To provide the image for the splash screen, use transferSplashImage, prior to launching the intent. It is recommended to also show the same splash screen in the app as soon as possible, prior to establishing a CustomTabConnection. The Trusted Web Activity provider should ensure seamless transition of the splash screen from the app onto the top of webpage being loaded. The splash screen will be removed on the first paint of the page, or when the page load fails.

setToolbarColor

Added in 1.2.0
Deprecated in 1.3.0
fun setToolbarColor(color: @ColorInt Int): TrustedWebActivityIntentBuilder

Sets the color applied to the toolbar and the status bar, see setToolbarColor. When a Trusted Web Activity is on the verified origin, the toolbar is hidden, so the color applies only to the status bar. When it's on an unverified origin, the toolbar is shown, and the color applies to both toolbar and status bar.