TrustedWebUtils
class TrustedWebUtils
Class for utilities and convenience calls for opening a qualifying web page as a Trusted Web Activity. Trusted Web Activity is a fullscreen UI with no visible browser controls that hosts web pages meeting certain criteria. The full list of qualifications is at the implementing browser's discretion, but minimum recommended set is for the web page :
- To have declared delegate_permission/common.handle_all_urls relationship with the launching client application ensuring 1:1 trust between the Android native and web components. See https://developers.google.com/digital-asset-links/ for details.
- To work as a reliable, fast and engaging standalone component within the launching app's flow.
- To be accessible and operable even when offline.
onRelationshipValidationResult for sending details of the verification results.
Summary
Constants |
|
|---|---|
const String! |
EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY = "android.support.customtabs.extra.LAUNCH_AS_TRUSTED_WEB_ACTIVITY"Boolean extra that triggers a |
Public functions |
|
|---|---|
java-static Boolean |
areSplashScreensSupported(Returns whether the splash screens feature is supported by the given package. |
java-static Unit |
This function is deprecated. Use |
java-static Boolean |
@WorkerThreadTransfers the splash image to a Custom Tabs provider. |
Constants
EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY
const val EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY = "android.support.customtabs.extra.LAUNCH_AS_TRUSTED_WEB_ACTIVITY": String!
Boolean extra that triggers a CustomTabsIntent launch to be in a fullscreen UI with no browser controls.
Public functions
areSplashScreensSupported
java-static fun areSplashScreensSupported(
context: Context,
packageName: String,
version: String
): Boolean
Returns whether the splash screens feature is supported by the given package. Note: you can call this method prior to connecting to a CustomTabsService. This way, if true is returned, the splash screen can be shown as soon as possible.
| Parameters | |
|---|---|
context: Context |
|
packageName: String |
The package name of the Custom Tabs provider to check. |
version: String |
The splash screen version/feature you are testing for support. Use a value from |
| Returns | |
|---|---|
Boolean |
Whether the specified Custom Tabs provider supports the specified splash screen feature/version. |
java-static funlaunchAsTrustedWebActivity(
context: Context,
customTabsIntent: CustomTabsIntent,
uri: Uri
): Unit
Launch the given CustomTabsIntent as a Trusted Web Activity. The given CustomTabsIntent should have a valid CustomTabsSession associated with it during construction. Once the Trusted Web Activity is launched, browser side implementations may have their own fallback behavior (e.g. Showing the page in a custom tab UI with toolbar) based on qualifications listed above or more.
| Parameters | |
|---|---|
context: Context |
|
customTabsIntent: CustomTabsIntent |
The |
uri: Uri |
The web page to launch as Trusted Web Activity. |
transferSplashImage
@WorkerThread
java-static fun transferSplashImage(
context: Context,
file: File,
fileProviderAuthority: String,
packageName: String,
session: CustomTabsSession
): Boolean
Transfers the splash image to a Custom Tabs provider. The reading and decoding of the image happens synchronously, so it's recommended to call this method on a worker thread. This method should be called prior to launching the Activity. Pass additional parameters, such as background color, using setSplashScreenParams.
| Parameters | |
|---|---|
context: Context |
|
file: File |
|
fileProviderAuthority: String |
authority of |
packageName: String |
Package name of Custom Tabs provider. |
session: CustomTabsSession |
|
| Returns | |
|---|---|
Boolean |
True if the image was received and processed successfully. |