# WebViewCompat

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

*** ** * ** ***


```
class WebViewCompat
```

<br />

*** ** * ** ***

Compatibility version of `https://developer.android.com/reference/android/webkit/WebView.html`

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#CLASS) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = [https://developer.android.com/reference/java/lang/annotation/ElementType.html#METHOD, https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE, https://developer.android.com/reference/java/lang/annotation/ElementType.html#FIELD]) @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresOptIn(level = https://developer.android.com/reference/kotlin/androidx/annotation/RequiresOptIn.Level#ERROR) annotation https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.ExperimentalAsyncStartUp` Denotes that the async startup-related API (e.g `startupWebView`, ` ProcessGlobalConfig.setUiThreadStartupMode`) is experimental. |
| `@https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#CLASS) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = [https://developer.android.com/reference/java/lang/annotation/ElementType.html#METHOD, https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE, https://developer.android.com/reference/java/lang/annotation/ElementType.html#FIELD]) @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresOptIn(level = https://developer.android.com/reference/kotlin/androidx/annotation/RequiresOptIn.Level#ERROR) annotation https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.ExperimentalNavigate` Denotes that the Navigate API surface is experimental. |
| `interface https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback` Callback interface supplied to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#postVisualStateCallback(android.webkit.WebView,long,androidx.webkit.WebViewCompat.VisualStateCallback)` for receiving notifications about the visual state. |
| `interface https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` This listener receives messages sent on the JavaScript object which was injected by `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)`. |
| `@https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.ExperimentalAsyncStartUp interface https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebViewStartUpCallback` **This interface is deprecated.** This is set for removal in the next release, use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)` <br /> |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_END() = 1` Injection event for when all primary resources have been loaded. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_START() = 0` Injection event for when Document is first created, before the rest of the page loads. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.DOCUMENT_START_SCRIPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addDocumentStartJavaScript(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>)( webview: https://developer.android.com/reference/android/webkit/WebView.html, script: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds a JavaScript script to the `https://developer.android.com/reference/android/webkit/WebView.html` which will be executed in any frame whose origin matches `allowedOriginRules` when the document begins to load. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addJavaScriptOnEvent(android.webkit.WebView,java.lang.String,int,java.util.Set<java.lang.String>,androidx.webkit.JavaScriptExecutionWorld)( webview: https://developer.android.com/reference/android/webkit/WebView.html, script: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, injectionEvent: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld )` Adds a JavaScript script to the `https://developer.android.com/reference/android/webkit/WebView.html` which will be executed in any frame whose origin matches `allowedOriginRules` at the page lifecycle event specified in the execution world specified. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,androidx.webkit.NavigationListener)(webView: https://developer.android.com/reference/android/webkit/WebView.html, listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener)` Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to the given `https://developer.android.com/reference/android/webkit/WebView.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)( webView: https://developer.android.com/reference/android/webkit/WebView.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener )` Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to the given `https://developer.android.com/reference/android/webkit/WebView.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEB_MESSAGE_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)( webView: https://developer.android.com/reference/android/webkit/WebView.html, jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, listener: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener )` Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` to the `https://developer.android.com/reference/android/webkit/WebView.html` and injects a JavaScript object into each frame that the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` will listen on. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.JavaScriptExecutionWorld,androidx.webkit.WebViewCompat.WebMessageListener)( webView: https://developer.android.com/reference/android/webkit/WebView.html, jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld, listener: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener )` Adds a WebMessageListener to the `https://developer.android.com/reference/android/webkit/WebView.html` which will receive messages posted from the specified `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/webkit/WebMessagePortCompat!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView)(webview: https://developer.android.com/reference/android/webkit/WebView.html)` Creates a message channel to communicate with JS and returns the message ports that represent the endpoints of this message channel. |
| `java-static https://developer.android.com/reference/android/content/pm/PackageInfo.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` If WebView has already been loaded into the current process this method will return the package that was used to load it. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getExecutionWorld(android.webkit.WebView,java.lang.String)(webview: https://developer.android.com/reference/android/webkit/WebView.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Returns a JavaScriptExecutionWorld for the given name. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/Profile` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.MULTI_PROFILE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getProfile(android.webkit.WebView)(webView: https://developer.android.com/reference/android/webkit/WebView.html)` Gets the Profile associated with this WebView. |
| `java-static https://developer.android.com/reference/android/net/Uri.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl()()` Returns a URL pointing to the privacy policy for Safe Browsing reporting. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.GET_VARIATIONS_HEADER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getVariationsHeader()()` Gets the WebView variations encoded to be used as the X-Client-Data HTTP header. |
| `java-static https://developer.android.com/reference/android/webkit/WebChromeClient.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.GET_WEB_CHROME_CLIENT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getWebChromeClient(android.webkit.WebView)(webview: https://developer.android.com/reference/android/webkit/WebView.html)` Gets the WebChromeClient. |
| `java-static https://developer.android.com/reference/android/webkit/WebViewClient.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.GET_WEB_VIEW_CLIENT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getWebViewClient(android.webkit.WebView)(webview: https://developer.android.com/reference/android/webkit/WebView.html)` Gets the WebViewClient for the WebView argument. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcess?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.GET_WEB_VIEW_RENDERER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getWebViewRenderProcess(android.webkit.WebView)(webview: https://developer.android.com/reference/android/webkit/WebView.html)` Gets the WebView renderer associated with this WebView. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getWebViewRenderProcessClient(android.webkit.WebView)(webview: https://developer.android.com/reference/android/webkit/WebView.html)` Gets the renderer client object associated with this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.MUTE_AUDIO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#isAudioMuted(android.webkit.WebView)(webView: https://developer.android.com/reference/android/webkit/WebView.html)` Returns whether this WebView is muted. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.MULTI_PROCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#isMultiProcessEnabled()()` Returns true if `https://developer.android.com/reference/android/webkit/WebView.html` is running in multi process mode. |
| `java-static https://developer.android.com/reference/kotlin/androidx/webkit/Navigation` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEBVIEW_NAVIGATE_EXPERIMENTAL_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.ExperimentalNavigate https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#navigate(android.webkit.WebView,java.lang.String,androidx.webkit.NavigationParameters)(webview: https://developer.android.com/reference/android/webkit/WebView.html, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, params: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationParameters)` Navigates the provided WebView to the given url, with configuration provided by `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationParameters`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.VISUAL_STATE_CALLBACK, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#postVisualStateCallback(android.webkit.WebView,long,androidx.webkit.WebViewCompat.VisualStateCallback)( webview: https://developer.android.com/reference/android/webkit/WebView.html, requestId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback )` Posts a `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback`, which will be called when the current state of the WebView is ready to be drawn. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.POST_WEB_MESSAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,androidx.webkit.WebMessageCompat,android.net.Uri)( webview: https://developer.android.com/reference/android/webkit/WebView.html, message: https://developer.android.com/reference/kotlin/androidx/webkit/WebMessageCompat, targetOrigin: https://developer.android.com/reference/android/net/Uri.html )` Post a message to main frame. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderOperationCallback)( webView: https://developer.android.com/reference/android/webkit/WebView.html, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?, callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback )` Starts a URL prerender request for this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/webkit/Profile.ExperimentalUrlPrefetch https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderParameters,androidx.webkit.PrerenderOperationCallback)( webView: https://developer.android.com/reference/android/webkit/WebView.html, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?, callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, params: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters, callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback )` The same as `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderOperationCallback)`, but allows customizing the request by providing `https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/webkit/Profile.ExperimentalUrlPrefetch [prerenderUrlAsync](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.SpeculativeLoadingParameters,androidx.webkit.PrerenderOperationCallback))( webView: https://developer.android.com/reference/android/webkit/WebView.html, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?, callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, params: https://developer.android.com/reference/kotlin/androidx/webkit/SpeculativeLoadingParameters, callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback )` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderParameters,androidx.webkit.PrerenderOperationCallback)` instead. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#removeNavigationListener(android.webkit.WebView,androidx.webkit.NavigationListener)(webView: https://developer.android.com/reference/android/webkit/WebView.html, listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener)` Removes a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` from the given `https://developer.android.com/reference/android/webkit/WebView.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEB_MESSAGE_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#removeWebMessageListener(android.webkit.WebView,java.lang.String)(webview: https://developer.android.com/reference/android/webkit/WebView.html, jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Removes the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` associated with ` jsObjectName`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#removeWebMessageListener(android.webkit.WebView,androidx.webkit.JavaScriptExecutionWorld,java.lang.String)( webview: https://developer.android.com/reference/android/webkit/WebView.html, world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld, jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html )` Removes a WebMessageListener from the `https://developer.android.com/reference/android/webkit/WebView.html` in the specified execution world. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SAVE_STATE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") @https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#saveState(android.webkit.WebView,android.os.Bundle,int,boolean)( webView: https://developer.android.com/reference/android/webkit/WebView.html, outState: https://developer.android.com/reference/android/os/Bundle.html, maxSizeBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, includeForwardState: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Saves the state of the provided WebView, such as for use with `https://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.MUTE_AUDIO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setAudioMuted(android.webkit.WebView,boolean)(webView: https://developer.android.com/reference/android/webkit/WebView.html, mute: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Mute or un-mute this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.DEFAULT_TRAFFICSTATS_TAGGING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setDefaultTrafficStatsTag(int)(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the default `https://developer.android.com/reference/android/net/TrafficStats.html` tag to use when accounting socket traffic caused by WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.MULTI_PROFILE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setProfile(android.webkit.WebView,java.lang.String)(webView: https://developer.android.com/reference/android/webkit/WebView.html, profileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the Profile with its name as the current Profile for this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SAFE_BROWSING_ALLOWLIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>)( hosts: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>? )` Configures a set of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "setSafeBrowsingAllowlist(new HashSet<>(hosts), callback)", imports = [""java.util.HashSet""]) @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SAFE_BROWSING_WHITELIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") [setSafeBrowsingWhitelist](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setSafeBrowsingWhitelist(java.util.List<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>))( hosts: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>? )` **This function is deprecated.** Please use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>)` instead. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setWebViewRenderProcessClient(android.webkit.WebView,androidx.webkit.WebViewRenderProcessClient)( webview: https://developer.android.com/reference/android/webkit/WebView.html, webViewRenderProcessClient: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient? )` Sets the renderer client object associated with this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setWebViewRenderProcessClient(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.WebViewRenderProcessClient)( webview: https://developer.android.com/reference/android/webkit/WebView.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, webViewRenderProcessClient: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient )` Sets the renderer client object associated with this WebView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") [startSafeBrowsing](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startSafeBrowsing(android.content.Context,android.webkit.ValueCallback<java.lang.Boolean>))(context: https://developer.android.com/reference/android/content/Context.html, callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>?)` **This function is deprecated.** In WebView version 122.0.6174.0 and later, this initialization is done automatically, so there is no need to call this API. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.ExperimentalAsyncStartUp @https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread [startUpWebView](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewCompat.WebViewStartUpCallback))( context: https://developer.android.com/reference/android/content/Context.html, config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig, callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebViewStartUpCallback )` **This function is deprecated.** This is an experimental version and is planned to be removed in the next release. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)( context: https://developer.android.com/reference/android/content/Context.html, config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig, callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver<https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpResult!, https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartupException!> )` Asynchronously trigger WebView startup. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,java.util.concurrent.Executor,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)( context: https://developer.android.com/reference/android/content/Context.html, config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig, callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver<https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpResult!, https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartupException!> )` Asynchronously trigger WebView startup, invoking `callback` on `callbackExecutor`. |

## Constants

### INJECTION_EVENT_DOCUMENT_END

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

```
const val INJECTION_EVENT_DOCUMENT_END = 1: Int
```

Injection event for when all primary resources have been loaded. Corresponds to DomContentLoaded. See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addJavaScriptOnEvent(android.webkit.WebView,java.lang.String,int,java.util.Set<java.lang.String>,androidx.webkit.JavaScriptExecutionWorld)` for usage.

### INJECTION_EVENT_DOCUMENT_START

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

```
const val INJECTION_EVENT_DOCUMENT_START = 0: Int
```

Injection event for when Document is first created, before the rest of the page loads. See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addJavaScriptOnEvent(android.webkit.WebView,java.lang.String,int,java.util.Set<java.lang.String>,androidx.webkit.JavaScriptExecutionWorld)` for usage.

## Public functions

### addDocumentStartJavaScript

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.DOCUMENT_START_SCRIPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun addDocumentStartJavaScript(
    webview: WebView,
    script: String,
    allowedOriginRules: (Mutable)Set<String!>
): ScriptHandler
```

Adds a JavaScript script to the `https://developer.android.com/reference/android/webkit/WebView.html` which will be executed in any frame whose origin matches `allowedOriginRules` when the document begins to load.

Note that the script will run before any of the page's JavaScript code and the DOM tree might not be ready at this moment. It will block the loading of the page until it's finished, so should be kept as short as possible.

The injected object from `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` API will be injected first and the script can rely on the injected object to send messages to the app.

The script will only run in frames which begin loading after the call returns, therefore it should typically be called before making any `loadUrl()`, `loadData()` or `loadDataWithBaseURL()` call to load the page.

This method can be called multiple times to inject multiple scripts. If more than one script matches a frame's origin, they will be executed in the order they were added.

See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` for the rules of the `allowedOriginRules` parameter.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#DOCUMENT_START_SCRIPT()`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `script: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The JavaScript script to be executed. |
| `allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | A set of matching rules for the allowed origins. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` | the `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler`, which is a handle for removing the script. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If one of the `allowedOriginRules` is invalid. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#DOCUMENT_START_SCRIPT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` |   |

### addJavaScriptOnEvent

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun addJavaScriptOnEvent(
    webview: WebView,
    script: String,
    injectionEvent: Int,
    allowedOriginRules: (Mutable)Set<String!>,
    world: JavaScriptExecutionWorld
): ScriptHandler
```

Adds a JavaScript script to the `https://developer.android.com/reference/android/webkit/WebView.html` which will be executed in any frame whose origin matches `allowedOriginRules` at the page lifecycle event specified in the execution world specified.

An object injected through the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.JavaScriptExecutionWorld,androidx.webkit.WebViewCompat.WebMessageListener)` API will be injected first and the script can rely on the injected object to send messages to the app. The script will only be able to call message listeners registered in the same execution world.

The script will only run in frames which begin loading after the call returns, therefore it should typically be called before making any `loadUrl()`, `loadData()` or `loadDataWithBaseURL()` call to load the page.

This method can be called multiple times to inject multiple scripts. If more than one script matches a frame's origin, they will be executed in the order they were added.

See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` for the rules of the `allowedOriginRules` parameter.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `script: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The JavaScript script to be executed. |
| `injectionEvent: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The lifecycle event to inject the script: either `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_START()` or `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_END()` |
| `allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | A set of matching rules for the allowed origins. |
| `world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld` | The execution world to inject the script. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` | the `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler`, which is a handle for removing the script. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If one of the `allowedOriginRules` is invalid or if the `world` is invalid. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ScriptHandler` |   |

### addNavigationListener

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

```
@RequiresFeature(name = WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun addNavigationListener(webView: WebView, listener: NavigationListener): Unit
```

Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to the given `https://developer.android.com/reference/android/webkit/WebView.html`.

A listener can only be added to a WebView once. Attempting to add the same listener to the same WebView twice will result in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

The callback will be executed on the main thread using `https://developer.android.com/reference/android/os/Looper.html#getMainLooper()`. To specify the execution thread, use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)`.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` | The `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to add. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#NAVIGATION_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)` |   |

### addNavigationListener

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

```
@RequiresFeature(name = WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun addNavigationListener(
    webView: WebView,
    executor: Executor,
    listener: NavigationListener
): Unit
```

Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to the given `https://developer.android.com/reference/android/webkit/WebView.html`.

A listener can only be added to a WebView once. Attempting to add the same listener to the same WebView twice will result in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/java/util/concurrent/Executor.html` where callbacks to the `listener` will be executed. |
| `listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` | The `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to add. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the `listener` has already been added to the `webView`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#NAVIGATION_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### addWebMessageListener

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.WEB_MESSAGE_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun addWebMessageListener(
    webView: WebView,
    jsObjectName: String,
    allowedOriginRules: (Mutable)Set<String!>,
    listener: WebViewCompat.WebMessageListener
): Unit
```

Adds a `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` to the `https://developer.android.com/reference/android/webkit/WebView.html` and injects a JavaScript object into each frame that the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` will listen on.

The injected JavaScript object will be named `jsObjectName` in the global scope. This will inject the JavaScript object in any frame whose origin matches `
allowedOriginRules` for every navigation after this call, and the JavaScript object will be available immediately when the page begins to load.

Each `allowedOriginRules` entry must follow the format `SCHEME "://" [
HOSTNAME_PATTERN [ ":" PORT ] ]`, each part is explained in the below table:

| Rule | Description | Example |
|---|---|---|
| http/https with hostname | `SCHEME` is http or https; `HOSTNAME_PATTERN` is a regular hostname; ` PORT` is optional, when not present, the rule will match port `80` for http and port `443` for https. | - `https://foobar.com:8080` - Matches https:// URL on port 8080, whose normalized host is foobar.com. - `https://www.example.com` - Matches https:// URL on port 443, whose normalized host is www.example.com. |
| http/https with pattern matching | `SCHEME` is http or https; `HOSTNAME_PATTERN` is a sub-domain matching pattern with a leading `*.`; `PORT` is optional, when not present, the rule will match port `80` for http and port `443` for https. | - `https://*.example.com` - Matches https://calendar.example.com and https://foo.bar.example.com but not https://example.com. - `https://*.example.com:8080` - Matches https://calendar.example.com:8080 |
| http/https with IP literal | `SCHEME` is https or https; `HOSTNAME_PATTERN` is IP literal; `PORT` is optional, when not present, the rule will match port `80` for http and port `443` for https. | - `https://127.0.0.1` - Matches https:// URL on port 443, whose IPv4 address is 127.0.0.1 - `https://[::1]` or `https://[0:0::1]`- Matches any URL to the IPv6 loopback address with port 443. - `https://[::1]:99` - Matches any https:// URL to the IPv6 loopback on port 99. |
| Custom scheme | `SCHEME` is a custom scheme; `HOSTNAME_PATTERN` and `PORT` must not be present. | - `my-app-scheme://` - Matches any my-app-scheme:// URL. |
| `*` | Wildcard rule, matches any origin. | - `*` |

Note that this is a powerful API, as the JavaScript object will be injected when the frame's origin matches any one of the allowed origins. The HTTPS scheme is strongly recommended for security; allowing HTTP origins exposes the injected object to any potential network-based attackers. If a wildcard `"*"` is provided, it will inject the JavaScript object to all frames. A wildcard should only be used if the app wants **any** third party web page to be able to use the injected object. When using a wildcard, the app must treat received messages as untrustworthy and validate any data carefully.

This method can be called multiple times to inject multiple JavaScript objects.

Let's say the injected JavaScript object is named `myObject`. We will have following methods on that object once it is available to use:

```kotlin
// Web page (in JavaScript)
// message needs to be a JavaScript String or ArrayBuffer, MessagePorts is an optional
// parameter.
myObject.postMessage(message[, MessagePorts])

          
// To receive messages posted from the app side, assign a function to the "onmessage"
// property. This function should accept a single "event" argument. "event" has a "data"
// property, which is the message String or ArrayBuffer from the app side.
myObject.onmessage = function(event) { ... }

          
// To be compatible with DOM EventTarget's addEventListener, it accepts type and listener
// parameters, where type can be only "message" type and listener can only be a JavaScript
// function for myObject. An event object will be passed to listener with a "data" property,
// which is the message String or ArrayBuffer from the app side.
myObject.addEventListener(type, listener)

          
// To be compatible with DOM EventTarget's removeEventListener, it accepts type and listener
// parameters, where type can be only "message" type and listener can only be a JavaScript
// function for myObject.
myObject.removeEventListener(type, listener)

        
```

We start the communication between JavaScript and the app from the JavaScript side. In order to send message from the app to JavaScript, it needs to post a message from JavaScript first, so the app will have a `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptReplyProxy` object to respond. Example:

```kotlin
// Web page (in JavaScript)
myObject.onmessage = function(event) {
  // prints "Got it!" when we receive the app's response.
  console.log(event.data);
}
myObject.postMessage("I'm ready!");
```

```kotlin
// App (in Java)
WebMessageListener myListener = new WebMessageListener() {
  @Override
  public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin,
           boolean isMainFrame, JavaScriptReplyProxy replyProxy) {
    // do something about view, message, sourceOrigin and isMainFrame.
    replyProxy.postMessage("Got it!");
  }
};
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) {
  WebViewCompat.addWebMessageListener(webView, "myObject", rules, myListener);
}
```

Suppose the communication is already setup, to send ArrayBuffer from the app to web, it needs to check feature flag(`https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()`). Here is a example to send file content from app to web:

```kotlin
// App (in Java)
WebMessageListener myListener = new WebMessageListener() {
  @Override
  public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin,
           boolean isMainFrame, JavaScriptReplyProxy replyProxy) {
    // Communication is setup, send file data to web.
    if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER)) {
      // Suppose readFileData method is to read content from file.
      byte[] fileData = readFileData("myFile.dat");
      replyProxy.postMessage(fileData);
    }
  }
}
```

```kotlin
// Web page (in JavaScript)
myObject.onmessage = function(event) {
  if (event.data instanceof ArrayBuffer) {
    const data = event.data;  // Received file content from app.
    const dataView = new DataView(data);
    // Consume file content by using JavaScript DataView to access ArrayBuffer.
  }
}
myObject.postMessage("Setup!");
```

Suppose the communication is already setup, and feature flag `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()` is check. Here is a example to download image in WebView, and send to app:

```kotlin
// Web page (in JavaScript)
const response = await fetch('example.jpg');
if (response.ok) {
    const imageData = await response.arrayBuffer();
    myObject.postMessage(imageData);
}
```

```kotlin
// App (in Java)
WebMessageListener myListener = new WebMessageListener() {
  @Override
  public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin,
           boolean isMainFrame, JavaScriptReplyProxy replyProxy) {
    if (message.getType() == WebMessageCompat.TYPE_ARRAY_BUFFER) {
      byte[] imageData = message.getArrayBuffer();
      // do something like draw image on ImageView.
    }
  }
};
```

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The name for the injected JavaScript object for this `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener`. |
| `allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | A set of matching rules for the allowed origins. |
| `listener: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` | The `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` to handle postMessage() calls on the JavaScript object. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If one of the `allowedOriginRules` is invalid. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_MESSAGE_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptReplyProxy` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` |   |

### addWebMessageListener

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun addWebMessageListener(
    webView: WebView,
    jsObjectName: String,
    allowedOriginRules: (Mutable)Set<String!>,
    world: JavaScriptExecutionWorld,
    listener: WebViewCompat.WebMessageListener
): Unit
```

Adds a WebMessageListener to the `https://developer.android.com/reference/android/webkit/WebView.html` which will receive messages posted from the specified `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld`.

Note that WebMessageListeners added through this API are keyed on both name and world. `jsObjectName` only need to be unique per world. That is, it is possible to add the same `jsObjectName` to 2 or more worlds.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The name of the JavaScript object to be injected. |
| `allowedOriginRules: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | A set of matching rules for the allowed origins. |
| `world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld` | The `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld` in which to add the listener. |
| `listener: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` | The listener to receive messages. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the `world` is invalid. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### createWebMessageChannel

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun createWebMessageChannel(webview: WebView): Array<WebMessagePortCompat!>
```

Creates a message channel to communicate with JS and returns the message ports that represent the endpoints of this message channel. The HTML5 message channel functionality is described [here](https://html.spec.whatwg.org/multipage/comms.html#messagechannel)

The returned message channels are entangled and already in started state.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/webkit/WebMessagePortCompat!>` | an array of size two, containing the two message ports that form the message channel. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#CREATE_WEB_MESSAGE_CHANNEL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getCurrentWebViewPackage

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

```
@AnyThread
java-static fun getCurrentWebViewPackage(context: Context): PackageInfo?
```

If WebView has already been loaded into the current process this method will return the package that was used to load it. Otherwise, the package that would be used if the WebView was loaded right now will be returned; this does not cause WebView to be loaded, so this information may become outdated at any time. The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. It can also be changed through a Developer Setting. If the WebView package changes, any app process that has loaded WebView will be killed. The next time the app starts and loads WebView it will use the new WebView package instead.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/pm/PackageInfo.html?` | the current WebView package, or `null` if there is none. |

### getExecutionWorld

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getExecutionWorld(webview: WebView, name: String): JavaScriptExecutionWorld
```

Returns a JavaScriptExecutionWorld for the given name.

Use `https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld#PAGE_WORLD_NAME()` to get the default execution world. Worlds are associated with the `https://developer.android.com/reference/android/webkit/WebView.html` they are created for. Using a world from one WebView with another WebView will throw an exception.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView object to associate with the world. |
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The name of the execution world. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getProfile

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getProfile(webView: WebView): Profile
```

Gets the Profile associated with this WebView.

Gets the profile object set on this WebView using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setProfile(android.webkit.WebView,java.lang.String)`, or the default profile if it has not been changed.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView to get the profile object associated with. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/Profile` | the profile object set to this WebView. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the WebView has been destroyed. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#MULTI_PROFILE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getSafeBrowsingPrivacyPolicyUrl

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getSafeBrowsingPrivacyPolicyUrl(): Uri
```

Returns a URL pointing to the privacy policy for Safe Browsing reporting.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html` | the url pointing to a privacy policy document which can be displayed to users. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SAFE_BROWSING_PRIVACY_POLICY_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getVariationsHeader

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.GET_VARIATIONS_HEADER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getVariationsHeader(): String
```

Gets the WebView variations encoded to be used as the X-Client-Data HTTP header.

The app is responsible for adding the X-Client-Data header to any request that may use variations metadata, such as requests to Google web properties. The returned string will be a base64 encoded ClientVariations proto: <https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto>

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the variations header. The string may be empty if the header is not available. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#GET_VARIATIONS_HEADER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String, java.util.Map&lt;java.lang.String,java.lang.String&gt;)` |   |

### getWebChromeClient

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.GET_WEB_CHROME_CLIENT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getWebChromeClient(webview: WebView): WebChromeClient?
```

Gets the WebChromeClient.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebChromeClient.html?` | the WebChromeClient, or `null` if not yet set |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#GET_WEB_CHROME_CLIENT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getWebViewClient

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.GET_WEB_VIEW_CLIENT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getWebViewClient(webview: WebView): WebViewClient
```

Gets the WebViewClient for the WebView argument.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebViewClient.html` | the WebViewClient, or a default client if not yet set |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#GET_WEB_VIEW_CLIENT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getWebViewRenderProcess

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.GET_WEB_VIEW_RENDERER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getWebViewRenderProcess(webview: WebView): WebViewRenderProcess?
```

Gets the WebView renderer associated with this WebView.

In Android O and above, WebView may run in "multiprocess" mode. In multiprocess mode, rendering of web content is performed by a sandboxed renderer process separate to the application process. This renderer process may be shared with other WebViews in the application, but is not shared with other application processes.

If WebView is running in multiprocess mode, this method returns a handle to the renderer process associated with the WebView, which can be used to control the renderer process.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcess?` | the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcess` renderer handle associated with this `https://developer.android.com/reference/android/webkit/WebView.html`, or `null` if WebView is not running in multiprocess mode. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#GET_WEB_VIEW_RENDERER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### getWebViewRenderProcessClient

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun getWebViewRenderProcessClient(webview: WebView): WebViewRenderProcessClient?
```

Gets the renderer client object associated with this WebView.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient?` | the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` object associated with this WebView, if one has been set via `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setWebViewRenderProcessClient(android.webkit.WebView,androidx.webkit.WebViewRenderProcessClient)` or `null` otherwise. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### isAudioMuted

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.MUTE_AUDIO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun isAudioMuted(webView: WebView): Boolean
```

Returns whether this WebView is muted.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView for which to check mute status. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if the WebView is muted, false otherwise. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#MUTE_AUDIO()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### isMultiProcessEnabled

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.MULTI_PROCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun isMultiProcessEnabled(): Boolean
```

Returns true if `https://developer.android.com/reference/android/webkit/WebView.html` is running in multi process mode.

In Android O and above, WebView may run in "multiprocess" mode. In multiprocess mode, rendering of web content is performed by a sandboxed renderer process separate to the application process. This renderer process may be shared with other WebViews in the application, but is not shared with other application processes.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#MULTI_PROCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### navigate

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

```
@RequiresFeature(name = WebViewFeature.WEBVIEW_NAVIGATE_EXPERIMENTAL_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@WebViewCompat.ExperimentalNavigate
java-static fun navigate(webview: WebView, url: String, params: NavigationParameters): Navigation
```

Navigates the provided WebView to the given url, with configuration provided by `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationParameters`.

Note that this method is more flexible than `https://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)`, with more features available on the builder and different header handling, (see `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationParameters.Builder#addAdditionalHeader(java.lang.String,java.lang.String)`).

Note that this method will also cause the prefetch queue to be drained if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEBVIEW_NAVIGATE_DRAIN_PREFETCH()` feature is supported. This can be checked using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView to perform the navigation on. |
| `url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The URL to load. |
| `params: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationParameters` | The navigation parameters. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/Navigation` | Navigation object that can be used to track progress through NavigationListener callbacks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEBVIEW_NAVIGATE_EXPERIMENTAL_V1()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### postVisualStateCallback

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.VISUAL_STATE_CALLBACK, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun postVisualStateCallback(
    webview: WebView,
    requestId: Long,
    callback: WebViewCompat.VisualStateCallback
): Unit
```

Posts a `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback`, which will be called when the current state of the WebView is ready to be drawn.

Because updates to the DOM are processed asynchronously, updates to the DOM may not immediately be reflected visually by subsequent `https://developer.android.com/reference/android/webkit/WebView.html#onDraw(android.graphics.Canvas)` invocations. The `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback` provides a mechanism to notify the caller when the contents of the DOM at the current time are ready to be drawn the next time the `https://developer.android.com/reference/android/webkit/WebView.html` draws.

The next draw after the callback completes is guaranteed to reflect all the updates to the DOM up to the point at which the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback` was posted, but it may also contain updates applied after the callback was posted.

The state of the DOM covered by this API includes the following:

- primitive HTML elements (div, img, span, etc..)
- images
- CSS animations
- WebGL
- canvas

It does not include the state of:

<!-- -->

- the video tag

To guarantee that the `https://developer.android.com/reference/android/webkit/WebView.html` will successfully render the first frame after the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback#onComplete(long)` method has been called a set of conditions must be met:

- If the `https://developer.android.com/reference/android/webkit/WebView.html`'s visibility is set to `https://developer.android.com/reference/android/view/View.html#VISIBLE` then \* the `https://developer.android.com/reference/android/webkit/WebView.html` must be attached to the view hierarchy.
- If the `https://developer.android.com/reference/android/webkit/WebView.html`'s visibility is set to `https://developer.android.com/reference/android/view/View.html#INVISIBLE` then the `https://developer.android.com/reference/android/webkit/WebView.html` must be attached to the view hierarchy and must be made `https://developer.android.com/reference/android/view/View.html#VISIBLE` from the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback#onComplete(long)` method.
- If the `https://developer.android.com/reference/android/webkit/WebView.html`'s visibility is set to `https://developer.android.com/reference/android/view/View.html#GONE` then the `https://developer.android.com/reference/android/webkit/WebView.html` must be attached to the view hierarchy and its `https://developer.android.com/reference/android/widget/AbsoluteLayout.LayoutParams.html`'s width and height need to be set to fixed values and must be made `https://developer.android.com/reference/android/view/View.html#VISIBLE` from the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback#onComplete(long)` method.

When using this API it is also recommended to enable pre-rasterization if the `https://developer.android.com/reference/android/webkit/WebView.html` is off screen to avoid flickering. See `https://developer.android.com/reference/android/webkit/WebSettings.html#setOffscreenPreRaster(boolean)` for more details and do consider its caveats.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView to post to. |
| `requestId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | An id that will be returned in the callback to allow callers to match requests with callbacks. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.VisualStateCallback` | The callback to be invoked. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#VISUAL_STATE_CALLBACK()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### postWebMessage

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.POST_WEB_MESSAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun postWebMessage(
    webview: WebView,
    message: WebMessageCompat,
    targetOrigin: Uri
): Unit
```

Post a message to main frame. The embedded application can restrict the messages to a certain target origin. See [HTML5 spec](https://html.spec.whatwg.org/multipage/comms.html#posting-messages) for how target origin can be used.

A target origin can be set as a wildcard ("\*"). However this is not recommended. See the page above for security issues.

When posting a `https://developer.android.com/reference/kotlin/androidx/webkit/WebMessageCompat` with type `https://developer.android.com/reference/kotlin/androidx/webkit/WebMessageCompat#TYPE_ARRAY_BUFFER()`, this method should check if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns true for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()`. Example:

```kotlin
if (message.getType() == WebMessageCompat.TYPE_ARRAY_BUFFER) {
    if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER) {
        // ArrayBuffer message is supported, send message here.
        WebViewCompat.postWebMessage(webview, message, ...);
    }
}
```

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView to post to. |
| `message: https://developer.android.com/reference/kotlin/androidx/webkit/WebMessageCompat` | the WebMessage |
| `targetOrigin: https://developer.android.com/reference/android/net/Uri.html` | the target origin. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#POST_WEB_MESSAGE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### prerenderUrlAsync

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

```
@RequiresFeature(name = WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun prerenderUrlAsync(
    webView: WebView,
    url: String,
    cancellationSignal: CancellationSignal?,
    callbackExecutor: Executor,
    callback: PrerenderOperationCallback
): Unit
```

Starts a URL prerender request for this WebView. Must be called from the UI thread.

This WebView will match a prerender request to a navigation, such as a call to `https://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)` or a click on a hyperlink. The matching behavior is as follows:

- By default, if the server does not provide a `No-Vary-Search` HTTP header, an exact URL match is required.
- If the server provides a `No-Vary-Search` HTTP header, matching will be performed according to the rules specified by the header. See the [prerender documentation](https://developer.chrome.com/docs/web-platform/prerender-pages#no-vary-search) for more details.

To customize this behavior on the client side, use the overload that accepts `https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters`.

If a prerender request is matched, WebView will use the prerendered page. This includes requests that are still in progress. If no match is found, the URL will be handled normally (i.e., through a new network request).

Applications will still be responsible for calling `https://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)` to display web contents in a WebView.

A prerendered page can also match a navigation initiated by clicking a hyperlink.

Only supports HTTPS scheme.

The `https://developer.android.com/reference/android/os/CancellationSignal.html` will make the best effort to cancel an in-flight prerender request; however cancellation it is not guaranteed.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView for which we trigger the prerender request. |
| `url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the url associated with the prerender request. |
| `cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?` | used to trigger prerender cancellation. |
| `callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | the executor to resolve the callback with. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### prerenderUrlAsync

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

```
@RequiresFeature(name = WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
java-static fun prerenderUrlAsync(
    webView: WebView,
    url: String,
    cancellationSignal: CancellationSignal?,
    callbackExecutor: Executor,
    params: PrerenderParameters,
    callback: PrerenderOperationCallback
): Unit
```

The same as `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderOperationCallback)`, but allows customizing the request by providing `https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters`.

When `https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters` are provided, they determine the URL matching behavior, taking precedence over the default behavior or any `No-Vary-Search` header sent by the server. See `https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters` for more details on how to configure the matching algorithm.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView for which we trigger the prerender request. |
| `url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the url associated with the prerender request. |
| `cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?` | used to trigger prerender cancellation. |
| `callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | the executor to resolve the callback with. |
| `params: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderParameters` | parameters to customize the prerender request and its matching behavior. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### prerenderUrlAsync

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

```
@RequiresFeature(name = WebViewFeature.PRERENDER_WITH_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
java-static fun [prerenderUrlAsync](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.SpeculativeLoadingParameters,androidx.webkit.PrerenderOperationCallback))(
    webView: WebView,
    url: String,
    cancellationSignal: CancellationSignal?,
    callbackExecutor: Executor,
    params: SpeculativeLoadingParameters,
    callback: PrerenderOperationCallback
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderParameters,androidx.webkit.PrerenderOperationCallback)` instead.

The same as `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.PrerenderOperationCallback)`, but allows customizing the request by providing `https://developer.android.com/reference/kotlin/androidx/webkit/SpeculativeLoadingParameters`.

When `https://developer.android.com/reference/kotlin/androidx/webkit/SpeculativeLoadingParameters` are provided, they determine the URL matching behavior, taking precedence over the default behavior or any `No-Vary-Search` header sent by the server. See `https://developer.android.com/reference/kotlin/androidx/webkit/SpeculativeLoadingParameters` for more details on how to configure the matching algorithm.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView for which we trigger the prerender request. |
| `url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the url associated with the prerender request. |
| `cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html?` | used to trigger prerender cancellation. |
| `callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | the executor to resolve the callback with. |
| `params: https://developer.android.com/reference/kotlin/androidx/webkit/SpeculativeLoadingParameters` | parameters to customize the prerender request and its matching behavior. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/PrerenderOperationCallback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### removeNavigationListener

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

```
@RequiresFeature(name = WebViewFeature.NAVIGATION_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun removeNavigationListener(webView: WebView, listener: NavigationListener): Unit
```

Removes a `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` from the given `https://developer.android.com/reference/android/webkit/WebView.html`.

This method does nothing, if the `listener` has not previously been added with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)`.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `listener: https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` | The `https://developer.android.com/reference/kotlin/androidx/webkit/NavigationListener` to remove. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#NAVIGATION_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)` |   |

### removeWebMessageListener

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.WEB_MESSAGE_LISTENER, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun removeWebMessageListener(webview: WebView, jsObjectName: String): Unit
```

Removes the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener` associated with `
jsObjectName`.

Note that after this call, the injected JavaScript object is still in the JavaScript context, however any message sent after this call won't reach the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebMessageListener`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView object to remove from. |
| `jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The JavaScript object's name that was previously passed to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_MESSAGE_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)` |   |

### removeWebMessageListener

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.JS_INJECTION_IN_FRAME_AND_WORLD, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun removeWebMessageListener(
    webview: WebView,
    world: JavaScriptExecutionWorld,
    jsObjectName: String
): Unit
```

Removes a WebMessageListener from the `https://developer.android.com/reference/android/webkit/WebView.html` in the specified execution world.

If there are 2 listeners with the same name but in different worlds, this will only remove the web listener from the world specified. If there is no listener with `jsObjectName` in the world, this will be a no-op.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `world: https://developer.android.com/reference/kotlin/androidx/webkit/JavaScriptExecutionWorld` | The execution world from which to remove the listener. |
| `jsObjectName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The name of the JavaScript object that was previously added. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### saveState

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

```
@RequiresFeature(name = WebViewFeature.SAVE_STATE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun saveState(
    webView: WebView,
    outState: Bundle,
    maxSizeBytes: @IntRange(from = 1) Int,
    includeForwardState: Boolean
): Unit
```

Saves the state of the provided WebView, such as for use with `https://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)`. This is an extension of `https://developer.android.com/reference/android/webkit/WebView.html#saveState(android.os.Bundle)` and the returned state can be restored through `https://developer.android.com/reference/android/webkit/WebView.html#restoreState(android.os.Bundle)`.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the `https://developer.android.com/reference/android/webkit/WebView.html` whose state is to be saved. |
| `outState: https://developer.android.com/reference/android/os/Bundle.html` | the `https://developer.android.com/reference/android/os/Bundle.html` to store the state in. |
| `maxSizeBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the maximum size (in bytes) that the returned state can be. If the WebView contains more state, history entries further back will not be saved. |
| `includeForwardState: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | whether to include entries that can only be reached through going forward in history (such as through `https://developer.android.com/reference/android/webkit/WebView.html#goForward()`. Some apps don't give the user a way to go forward, so won't need to save the forward history. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SAVE_STATE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setAudioMuted

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.MUTE_AUDIO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setAudioMuted(webView: WebView, mute: Boolean): Unit
```

Mute or un-mute this WebView.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView for which to control muting. |
| `mute: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true to mute the WebView; false to un-mute the WebView. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#MUTE_AUDIO()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setDefaultTrafficStatsTag

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.DEFAULT_TRAFFICSTATS_TAGGING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setDefaultTrafficStatsTag(tag: Int): Unit
```

Sets the default `https://developer.android.com/reference/android/net/TrafficStats.html` tag to use when accounting socket traffic caused by WebView. If set, this tag is global for all requests sent by the WebView library within your app.

If no tag is set (e.g. this method isn't called), then Android accounts for the socket traffic caused by WebView as if the tag value were set to 0. See `https://developer.android.com/reference/android/net/TrafficStats.html#setThreadStatsTag(int)` for more information.

**NOTE**: Setting a tag disallows sharing of sockets with requests with other tags, which may adversely affect performance by prohibiting connection sharing. In other words, use of multiplexed sockets (e.g. HTTP/2 and QUIC) will only be allowed if all requests have the same socket tag. To minimize impact, you should not change the value of this tag often.

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the tag value used when accounting for socket traffic caused by the WebView library in your app. *Tags between `0xFFFFFF00` and `0xFFFFFFFF` are reserved and used internally by system services like `https://developer.android.com/reference/android/app/DownloadManager.html` when performing traffic on behalf of an application*. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#DEFAULT_TRAFFICSTATS_TAGGING()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setProfile

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setProfile(webView: WebView, profileName: String): Unit
```

Sets the Profile with its name as the current Profile for this WebView.

- This should be called before doing anything else with WebView other than attaching it to the view hierarchy.
- This should be only called if WebView is to use a Profile other than the default.
- This method will create the profile if it doesn't exist.

| Parameters |
|---|---|
| `webView: https://developer.android.com/reference/android/webkit/WebView.html` | the WebView to modify. |
| `profileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name of the profile to use in the passed `webView`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the WebView has been destroyed. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the previous profile has been accessed via a call to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#getProfile(android.webkit.WebView)`. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the profile has already been set previously via this method. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if `https://developer.android.com/reference/android/webkit/WebView.html#evaluateJavascript(java.lang.String, android.webkit.ValueCallback&lt;java.lang.String&gt;)` is called on the WebView before this method. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the WebView has previously navigated to a web page. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#MULTI_PROFILE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setSafeBrowsingAllowlist

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.SAFE_BROWSING_ALLOWLIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setSafeBrowsingAllowlist(
    hosts: (Mutable)Set<String!>,
    callback: ValueCallback<Boolean!>?
): Unit
```

Configures a set of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The set is global for all the WebViews.

Each rule should take one of these:

| Rule | Example | Matches Subdomain |
|---|---|---|
| HOSTNAME | example.com | Yes |
| .HOSTNAME | .example.com | No |
| IPV4_LITERAL | 192.168.1.1 | No |
| IPV6_LITERAL_WITH_BRACKETS | \[10:20:30:40:50:60:70:80\] | No |

All other rules, including wildcards, are invalid.

The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2).

| Parameters |
|---|---|
| `hosts: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | the set of hosts for which to skip Safe Browsing checks |
| `callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>?` | will be called with `true` if hosts are successfully added to the allowlist, `false` if any hosts are malformed. The callback will be run on the UI thread |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SAFE_BROWSING_ALLOWLIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setSafeBrowsingWhitelist

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

```
@AnyThread
@ReplaceWith(expression = "setSafeBrowsingAllowlist(new HashSet<>(hosts), callback)", imports = [""java.util.HashSet""])
@RequiresFeature(name = WebViewFeature.SAFE_BROWSING_WHITELIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun [setSafeBrowsingWhitelist](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setSafeBrowsingWhitelist(java.util.List<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>))(
    hosts: (Mutable)List<String!>,
    callback: ValueCallback<Boolean!>?
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Please use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>)` instead.

Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.

Each rule should take one of these:

| Rule | Example | Matches Subdomain |
|---|---|---|
| HOSTNAME | example.com | Yes |
| .HOSTNAME | .example.com | No |
| IPV4_LITERAL | 192.168.1.1 | No |
| IPV6_LITERAL_WITH_BRACKETS | \[10:20:30:40:50:60:70:80\] | No |

All other rules, including wildcards, are invalid.

The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2).

| Parameters |
|---|---|
| `hosts: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | the list of hosts |
| `callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>?` | will be called with `true` if hosts are successfully added to the allowlist. It will be called with `false` if any hosts are malformed . The callback will be run on the UI thread |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SAFE_BROWSING_WHITELIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setWebViewRenderProcessClient

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setWebViewRenderProcessClient(
    webview: WebView,
    webViewRenderProcessClient: WebViewRenderProcessClient?
): Unit
```

Sets the renderer client object associated with this WebView.

See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#setWebViewRenderProcessClient(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.WebViewRenderProcessClient)` for details, with the following differences:

Callbacks will execute directly on the thread on which this WebView was instantiated.

Passing `null` for `webViewRenderProcessClient` will clear the renderer client object for this WebView.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE()`.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | the `https://developer.android.com/reference/android/webkit/WebView.html` on which to monitor responsiveness. |
| `webViewRenderProcessClient: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient?` | the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` to set for callbacks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the WebViewFeature#WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE} feature is not supported. |

### setWebViewRenderProcessClient

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

```
@UiThread
@RequiresFeature(name = WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun setWebViewRenderProcessClient(
    webview: WebView,
    executor: Executor,
    webViewRenderProcessClient: WebViewRenderProcessClient
): Unit
```

Sets the renderer client object associated with this WebView.

The renderer client encapsulates callbacks relevant to WebView renderer state. See `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` for details.

Although many WebView instances may share a single underlying renderer, and renderers may live either in the application process, or in a sandboxed process that is isolated from the application process, instances of `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` are set per-WebView. Callbacks represent renderer events from the perspective of this WebView, and may or may not be correlated with renderer events affecting other WebViews.

| Parameters |
|---|---|
| `webview: https://developer.android.com/reference/android/webkit/WebView.html` | the `https://developer.android.com/reference/android/webkit/WebView.html` on which to monitor responsiveness. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | the `https://developer.android.com/reference/java/util/concurrent/Executor.html` that will be used to execute callbacks. |
| `webViewRenderProcessClient: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` | the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewRenderProcessClient` to set for callbacks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### startSafeBrowsing

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

```
@AnyThread
@RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
java-static fun [startSafeBrowsing](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startSafeBrowsing(android.content.Context,android.webkit.ValueCallback<java.lang.Boolean>))(context: Context, callback: ValueCallback<Boolean!>?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> In WebView version 122.0.6174.0 and later, this initialization is done automatically, so there is no need to call this API. If called, this API will invoke the `callback` immediately with `true`, given that Safe Browsing is enabled and supported on the device.

Starts Safe Browsing initialization.

URL loads are not guaranteed to be protected by Safe Browsing until after `callback` is invoked with `true`. Safe Browsing is not fully supported on all devices. For those devices `callback` will receive `false`.

This should not be called if Safe Browsing has been disabled by manifest tag or `https://developer.android.com/reference/android/webkit/WebSettings.html#setSafeBrowsingEnabled(boolean)`. This prepares resources used for Safe Browsing.

This should be called with the Application Context (and will always use the Application context to do its work regardless).

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | Application Context. |
| `callback: https://developer.android.com/reference/android/webkit/ValueCallback.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html!>?` | will be called on the UI thread with `true` if initialization is successful, `false` otherwise. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#START_SAFE_BROWSING()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### startUpWebView

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

```
@WebViewCompat.ExperimentalAsyncStartUp
@AnyThread
java-static fun [startUpWebView](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewCompat.WebViewStartUpCallback))(
    context: Context,
    config: WebViewStartUpConfig,
    callback: WebViewCompat.WebViewStartUpCallback
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This is an experimental version and is planned to be removed in the next release. Use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)` instead.

Asynchronously trigger WebView startup.

WebView startup is a time-consuming process that is normally triggered during the first usage of WebView related APIs. WebView startup happens once per process. For example, the first call to `new WebView()` can take longer to complete than future calls due to WebView startup being triggered. The Android UI thread remains blocked till the startup completes.

This method allows callers to trigger WebView startup at a time of their choosing.

There are performance improvements this API provides. This method ensures that the portions of WebView startup which are able to run in the background will do so. Other portions of startup will still run on the UI thread.

Any APIs in `android.webkit` and `androidx.webkit` (including `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature`) MUST only be called after the callback is invoked in order to ensure the maximum benefit. There is no feature check or call to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature` required for using this method.

This API can be called multiple times. The callback will be called promptly if startup has already completed.

This is an experimental API and unsuitable for non-experimental use. This method can be removed in future versions of the library.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | Application Context. |
| `config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig` | configuration for startup. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat.WebViewStartUpCallback` | the callback triggered when WebView startup is complete. This will be called on the main looper (Looper.getMainLooper()). |

### startUpWebView

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

```
@AnyThread
java-static fun startUpWebView(
    context: Context,
    config: WebViewStartUpConfig,
    callback: WebViewOutcomeReceiver<WebViewStartUpResult!, WebViewStartupException!>
): Unit
```

Asynchronously trigger WebView startup.

WebView startup is a time-consuming process that is normally triggered during the first usage of WebView related APIs. WebView startup happens once per process. For example, the first call to `new WebView()` can take longer to complete than future calls due to WebView startup being triggered. The Android UI thread remains blocked till the startup completes.

This method allows callers to trigger WebView startup at a time of their choosing.

There are performance improvements this API provides. This method ensures that the portions of WebView startup which are able to run in the background will do so. Other portions of startup will still run on the UI thread.

Any APIs in `android.webkit` and `androidx.webkit` (including `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature`) MUST only be called after the callback is invoked in order to ensure the maximum benefit. There is no feature check or call to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature` required for using this method.

This API can be called multiple times. The callback will be called promptly if startup has already completed.

Startup is not expected to fail under normal circumstances, but can in rare cases. If a failure has been reported to the callback, calling any other WebView APIs is likely to throw an exception or immediately crash, and should be avoided if possible.

The callback will be executed on the main thread using `https://developer.android.com/reference/android/os/Looper.html#getMainLooper()`. To specify the execution thread for the callback, use `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,java.util.concurrent.Executor,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)`. Note that `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig#getBackgroundExecutor()` is only used by WebView to run background startup tasks, not to invoke `callback`.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | Application Context. |
| `config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig` | configuration for startup. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver<https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpResult!, https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartupException!>` | the callback triggered when WebView startup is complete or fails. This will be called on the main looper (`https://developer.android.com/reference/android/os/Looper.html#getMainLooper()`). |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,java.util.concurrent.Executor,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)` |   |

### startUpWebView

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

```
@AnyThread
java-static fun startUpWebView(
    context: Context,
    config: WebViewStartUpConfig,
    callbackExecutor: Executor,
    callback: WebViewOutcomeReceiver<WebViewStartUpResult!, WebViewStartupException!>
): Unit
```

Asynchronously trigger WebView startup, invoking `callback` on `callbackExecutor`.

This method functions as `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)`, but invokes `callback` on the provided `callbackExecutor` instead of the main looper.

Note that `callbackExecutor` only controls where `callback` is invoked, whereas `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig#getBackgroundExecutor()` is used by WebView to run background startup tasks.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | Application Context. |
| `config: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpConfig` | configuration for startup. |
| `callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | the `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which `callback` will be invoked. |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver<https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartUpResult!, https://developer.android.com/reference/kotlin/androidx/webkit/WebViewStartupException!>` | the callback triggered when WebView startup is complete or fails. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)` |   |