NavigationParameters.Builder


public final class NavigationParameters.Builder


A Builder for NavigationParameters.

Summary

Public constructors

Constructor for NavigationParameters builder which sets parameter defaults.

Public methods

@NonNull NavigationParameters.Builder

Adds an additional HTTP header to the request.

@NonNull NavigationParameters.Builder
addAdditionalHeaders(@NonNull Map<StringString> additionalHeaders)

Adds multiple additional HTTP headers to the request, as if addAdditionalHeader were called multiple times with each key-value pair of the map.

@NonNull NavigationParameters
@RequiresFeature(name = WebViewFeature.WEBVIEW_NAVIGATE_EXPERIMENTAL_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
build()

Use to finish building the NavigationParameters.

@NonNull NavigationParameters.Builder
setShouldReplaceCurrentEntry(boolean shouldReplaceCurrentEntry)

If true, the navigation will replace the current entry in the WebView's history, meaning that the current entry will not be reachable through WebView#goBack.

Public constructors

Builder

public Builder()

Constructor for NavigationParameters builder which sets parameter defaults.

Public methods

addAdditionalHeader

public @NonNull NavigationParameters.Builder addAdditionalHeader(@NonNull String key, @NonNull String value)

Adds an additional HTTP header to the request. Note that if the header is set by default by this WebView, such as those controlling caching, accept types or the User-Agent, it may be overridden by this WebView's default.

Unlike headers passed to loadUrl, additional headers passed here are tied to the navigation, meaning that subsequent user triggered navigations to the same URL will not have those headers applied. If called multiple times for the same key, the latest value will be used.

Header keys must be RFC 2616-compliant.

addAdditionalHeaders

public @NonNull NavigationParameters.Builder addAdditionalHeaders(@NonNull Map<StringString> additionalHeaders)

Adds multiple additional HTTP headers to the request, as if addAdditionalHeader were called multiple times with each key-value pair of the map. See addAdditionalHeader for more information.

build

@RequiresFeature(name = WebViewFeature.WEBVIEW_NAVIGATE_EXPERIMENTAL_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
public @NonNull NavigationParameters build()

Use to finish building the NavigationParameters.

This method should only be called if isFeatureSupported returns true for WEBVIEW_NAVIGATE_EXPERIMENTAL_V1.

Returns
@NonNull NavigationParameters

built NavigationParameters object.

setShouldReplaceCurrentEntry

public @NonNull NavigationParameters.Builder setShouldReplaceCurrentEntry(boolean shouldReplaceCurrentEntry)

If true, the navigation will replace the current entry in the WebView's history, meaning that the current entry will not be reachable through WebView#goBack. Defaults to false.