WebViewStartUpConfig.Builder


@WebViewCompat.ExperimentalAsyncStartUp
class WebViewStartUpConfig.Builder


Summary

Public constructors

Builder(executor: Executor)

Builder for WebViewStartUpConfig.

Public functions

WebViewStartUpConfig

Build and return a WebViewStartUpConfig object.

WebViewStartUpConfig.Builder

Specifies a set of profiles to load before the startup callback is invoked.

WebViewStartUpConfig.Builder
setShouldRunUiThreadStartUpTasks(
    shouldRunUiThreadStartUpTasks: Boolean
)

Setter to run only parts of startup that doesn't block the UI thread.

Public constructors

Builder

Added in 1.13.0
Builder(executor: Executor)

Builder for WebViewStartUpConfig.

Parameters
executor: Executor

The portions of WebView startup that can run on a background thread are scheduled on this executor. Blocking tasks will be run on the executor.

Public functions

build

Added in 1.13.0
fun build(): WebViewStartUpConfig

Build and return a WebViewStartUpConfig object.

Returns
WebViewStartUpConfig

immutable WebViewStartUpConfig object.

setProfilesToLoadDuringStartup

fun setProfilesToLoadDuringStartup(profiles: (Mutable)Set<String!>): WebViewStartUpConfig.Builder

Specifies a set of profiles to load before the startup callback is invoked.

This method allows you to specify a set of profiles that are guaranteed to have been loaded before the WebViewCompat.WebViewStartUpCallback is invoked. This can improve the performance of subsequent operations on those profiles at the cost of increasing the initial startup time.

Any profiles not specified in the set will not have resources allocated for them until they are used for the first time.

The behavior depends on the value provided:

  • Empty Set: No profiles are loaded, not even the default profile.
  • Non-empty Set: All profiles named in the set are loaded. These profiles will be created if they do not already exist.
If this method isn't called, the default profile will be loaded during startup.

Note: This method cannot be used if setShouldRunUiThreadStartUpTasks is set to false.

This method will be no-op if isStartupFeatureSupported returns false for STARTUP_FEATURE_SET_PROFILES_TO_LOAD.

Parameters
profiles: (Mutable)Set<String!>

A Set of profile names to pre-load or an empty Set to load none.

Returns
WebViewStartUpConfig.Builder

The Builder instance for method chaining.

Throws
java.lang.IllegalArgumentException

if this method is called when setShouldRunUiThreadStartUpTasks has been set to false.

setShouldRunUiThreadStartUpTasks

Added in 1.13.0
fun setShouldRunUiThreadStartUpTasks(
    shouldRunUiThreadStartUpTasks: Boolean
): WebViewStartUpConfig.Builder

Setter to run only parts of startup that doesn't block the UI thread.

WebView startup tasks that are required to run on the UI thread are not attempted when startUpWebView is called if set to false.

Defaults to `true`. If not set to `false`, UI thread startup tasks will be run.

Throws
java.lang.IllegalArgumentException

if this is set to false after a set of profiles to load has already been specified via setProfilesToLoadDuringStartup.