Register now for Android Dev Summit 2019!

WebViewAssetLoader.Builder

public static final class WebViewAssetLoader.Builder
extends Object

java.lang.Object
   ↳ androidx.webkit.WebViewAssetLoader.Builder


A builder class for constructing WebViewAssetLoader objects.

Summary

Public constructors

WebViewAssetLoader.Builder(Context context)

Public methods

WebViewAssetLoader.Builder allowHttp()

Allow using the HTTP scheme in addition to HTTPS.

WebViewAssetLoader build()

Build and return a WebViewAssetLoader object.

WebViewAssetLoader.Builder setAssetsHostingPath(String path)

Set the prefix path under which app assets should be hosted.

WebViewAssetLoader.Builder setDomain(String domain)

Set the domain under which app assets and resources can be accessed.

WebViewAssetLoader.Builder setResourcesHostingPath(String path)

Set the prefix path under which app resources should be hosted.

Inherited methods

Public constructors

WebViewAssetLoader.Builder

public WebViewAssetLoader.Builder (Context context)

Parameters
context Context: Context used to resolve resources/assets.

Public methods

allowHttp

public WebViewAssetLoader.Builder allowHttp ()

Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP.

Returns
WebViewAssetLoader.Builder WebViewAssetLoader.Builder object.

build

public WebViewAssetLoader build ()

Build and return a WebViewAssetLoader object.

Returns
WebViewAssetLoader immutable WebViewAssetLoader object.

Throws
IllegalArgumentException if the Builder received conflicting inputs.

setAssetsHostingPath

public WebViewAssetLoader.Builder setAssetsHostingPath (String path)

Set the prefix path under which app assets should be hosted. The default path for assets is "/assets/". The path must start and end with "/".

A custom prefix path can be used in conjunction with a custom domain, to avoid conflicts with real paths which may be hosted at that domain.

Parameters
path String: the path under which app assets should be hosted.

Returns
WebViewAssetLoader.Builder WebViewAssetLoader.Builder object.

Throws
IllegalArgumentException if the path is invalid.

setDomain

public WebViewAssetLoader.Builder setDomain (String domain)

Set the domain under which app assets and resources can be accessed. The default domain is "appassets.androidplatform.net"

Parameters
domain String: the domain on which app assets should be hosted.

Returns
WebViewAssetLoader.Builder WebViewAssetLoader.Builder object.

setResourcesHostingPath

public WebViewAssetLoader.Builder setResourcesHostingPath (String path)

Set the prefix path under which app resources should be hosted. The default path for resources is "/res/". The path must start and end with "/". A custom prefix path can be used in conjunction with a custom domain, to avoid conflicts with real paths which may be hosted at that domain.

Parameters
path String: the path under which app resources should be hosted.

Returns
WebViewAssetLoader.Builder WebViewAssetLoader.Builder object.

Throws
IllegalArgumentException if the path is invalid.