# WebViewAssetLoader.Builder

Artifact: [androidx.webkit:webkit](https://developer.android.com/jetpack/androidx/releases/webkit) [View Source](https://cs.android.com/search?q=file:androidx/webkit/WebViewAssetLoader.java+class:androidx.webkit.WebViewAssetLoader.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

*** ** * ** ***


```
public final class WebViewAssetLoader.Builder
```

<br />

*** ** * ** ***

A builder class for constructing `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder#addPathHandler(java.lang.String,androidx.webkit.WebViewAssetLoader.PathHandler)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html path, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.PathHandler handler )` Register a `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.PathHandler` for a specific path. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder#build()()` Build and return a `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder#setDomain(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html domain)` Set the domain under which app assets can be accessed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder#setHttpAllowed(boolean)(boolean httpAllowed)` Allow using the HTTP scheme in addition to HTTPS. |

## Public constructors

### Builder

Added in 1.1.0

```
public Builder()
```

## Public methods

### addPathHandler

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
public @NonNull WebViewAssetLoader.Builder addPathHandler(
    @NonNull String path,
    @NonNull WebViewAssetLoader.PathHandler handler
)
```

Register a `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.PathHandler` for a specific path.

The path should start and end with a `"/"` and it shouldn't collide with a real web path.

`WebViewAssetLoader` will try `PathHandlers` in the order they're registered, and will use whichever is the first to return a non-`null``https://developer.android.com/reference/android/webkit/WebResourceResponse.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html path` | the prefix path where this handler should be register. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.PathHandler handler` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.PathHandler` that handles requests for this path. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` object. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the path is invalid. |

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
public @NonNull WebViewAssetLoader build()
```

Build and return a `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` | immutable `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader` object. |

### setDomain

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
public @NonNull WebViewAssetLoader.Builder setDomain(@NonNull String domain)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html domain` | the domain on which app assets should be hosted. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` object. |

### setHttpAllowed

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
public @NonNull WebViewAssetLoader.Builder setHttpAllowed(boolean httpAllowed)
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` | `https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.Builder` object. |