# 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)

*** ** * ** ***


```
public 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/androidx/annotation/RequiresOptIn(level = https://developer.android.com/reference/androidx/annotation/RequiresOptIn.Level#ERROR) public annotation https://developer.android.com/reference/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/androidx/annotation/RequiresOptIn(level = https://developer.android.com/reference/androidx/annotation/RequiresOptIn.Level#ERROR) public annotation https://developer.android.com/reference/androidx/webkit/WebViewCompat.ExperimentalNavigate` Denotes that the Navigate API surface is experimental. |
| `public interface https://developer.android.com/reference/androidx/webkit/WebViewCompat.VisualStateCallback` Callback interface supplied to `https://developer.android.com/reference/androidx/webkit/WebViewCompat#postVisualStateCallback(android.webkit.WebView,long,androidx.webkit.WebViewCompat.VisualStateCallback)` for receiving notifications about the visual state. |
| `public interface https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener` This listener receives messages sent on the JavaScript object which was injected by `https://developer.android.com/reference/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/androidx/webkit/WebViewCompat.ExperimentalAsyncStartUp public interface https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebViewStartUpCallback` **This interface is deprecated.** This is set for removal in the next release, use `https://developer.android.com/reference/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewOutcomeReceiver<androidx.webkit.WebViewStartUpResult,androidx.webkit.WebViewStartupException>)` <br /> |

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

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

```
public static final int INJECTION_EVENT_DOCUMENT_END = 1
```

Injection event for when all primary resources have been loaded. Corresponds to DomContentLoaded. See `https://developer.android.com/reference/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)

```
public static final int INJECTION_EVENT_DOCUMENT_START = 0
```

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

## Public methods

### 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")
public static @NonNull ScriptHandler addDocumentStartJavaScript(
    @NonNull WebView webview,
    @NonNull String script,
    @NonNull Set<String> allowedOriginRules
)
```

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/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/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#DOCUMENT_START_SCRIPT()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html script` | The JavaScript script to be executed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> allowedOriginRules` | A set of matching rules for the allowed origins. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/ScriptHandler` | the `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#DOCUMENT_START_SCRIPT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/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/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")
public static @NonNull ScriptHandler addJavaScriptOnEvent(
    @NonNull WebView webview,
    @NonNull String script,
    int injectionEvent,
    @NonNull Set<String> allowedOriginRules,
    @NonNull JavaScriptExecutionWorld world
)
```

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/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/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html script` | The JavaScript script to be executed. |
| `int injectionEvent` | The lifecycle event to inject the script: either `https://developer.android.com/reference/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_START()` or `https://developer.android.com/reference/androidx/webkit/WebViewCompat#INJECTION_EVENT_DOCUMENT_END()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> allowedOriginRules` | A set of matching rules for the allowed origins. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/JavaScriptExecutionWorld world` | The execution world to inject the script. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/ScriptHandler` | the `https://developer.android.com/reference/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/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/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/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
public static void addNavigationListener(
    @NonNull WebView webView,
    @NonNull NavigationListener listener
)
```

Adds a `https://developer.android.com/reference/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/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/NavigationListener listener` | The `https://developer.android.com/reference/androidx/webkit/NavigationListener` to add. |

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

| See also |
|---|---|
| `https://developer.android.com/reference/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
public static void addNavigationListener(
    @NonNull WebView webView,
    @NonNull Executor executor,
    @NonNull NavigationListener listener
)
```

Adds a `https://developer.android.com/reference/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | `https://developer.android.com/reference/java/util/concurrent/Executor.html` where callbacks to the `listener` will be executed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/NavigationListener listener` | The `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#NAVIGATION_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void addWebMessageListener(
    @NonNull WebView webView,
    @NonNull String jsObjectName,
    @NonNull Set<String> allowedOriginRules,
    @NonNull WebViewCompat.WebMessageListener listener
)
```

Adds a `https://developer.android.com/reference/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/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:

```
// 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/androidx/webkit/JavaScriptReplyProxy` object to respond. Example:

```
// 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!");
```

```
// 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/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()`). Here is a example to send file content from app to web:

```
// 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);
    }
  }
}
```

```
// 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/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()` is check. Here is a example to download image in WebView, and send to app:

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

```
// 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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html jsObjectName` | The name for the injected JavaScript object for this `https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> allowedOriginRules` | A set of matching rules for the allowed origins. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener listener` | The `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#WEB_MESSAGE_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/webkit/JavaScriptReplyProxy` |   |
| `https://developer.android.com/reference/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")
public static void addWebMessageListener(
    @NonNull WebView webView,
    @NonNull String jsObjectName,
    @NonNull Set<String> allowedOriginRules,
    @NonNull JavaScriptExecutionWorld world,
    @NonNull WebViewCompat.WebMessageListener listener
)
```

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/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html jsObjectName` | The name of the JavaScript object to be injected. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> allowedOriginRules` | A set of matching rules for the allowed origins. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/JavaScriptExecutionWorld world` | The `https://developer.android.com/reference/androidx/webkit/JavaScriptExecutionWorld` in which to add the listener. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener listener` | 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/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/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")
public static @NonNull WebMessagePortCompat[] createWebMessageChannel(@NonNull WebView webview)
```

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://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html 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/androidx/webkit/WebViewFeature#CREATE_WEB_MESSAGE_CHANNEL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static @Nullable PackageInfo getCurrentWebViewPackage(@NonNull Context context)
```

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://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html 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")
public static @NonNull JavaScriptExecutionWorld getExecutionWorld(@NonNull WebView webview, @NonNull String name)
```

Returns a JavaScriptExecutionWorld for the given name.

Use `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The WebView object to associate with the world. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html name` | The name of the execution world. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/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/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")
public static @NonNull Profile getProfile(@NonNull WebView webView)
```

Gets the Profile associated with this WebView.

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView to get the profile object associated with. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#MULTI_PROFILE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @NonNull Uri getSafeBrowsingPrivacyPolicyUrl()
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html 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/androidx/webkit/WebViewFeature#SAFE_BROWSING_PRIVACY_POLICY_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @NonNull String getVariationsHeader()
```

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://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.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/androidx/webkit/WebViewFeature#GET_VARIATIONS_HEADER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @Nullable WebChromeClient getWebChromeClient(@NonNull WebView webview)
```

Gets the WebChromeClient.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html 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/androidx/webkit/WebViewFeature#GET_WEB_CHROME_CLIENT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @NonNull WebViewClient getWebViewClient(@NonNull WebView webview)
```

Gets the WebViewClient for the WebView argument.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html 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/androidx/webkit/WebViewFeature#GET_WEB_VIEW_CLIENT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @Nullable WebViewRenderProcess getWebViewRenderProcess(@NonNull WebView webview)
```

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://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/webkit/WebViewRenderProcess` | the `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#GET_WEB_VIEW_RENDERER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static @Nullable WebViewRenderProcessClient getWebViewRenderProcessClient(@NonNull WebView webview)
```

Gets the renderer client object associated with this WebView.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/webkit/WebViewRenderProcessClient` | the `https://developer.android.com/reference/androidx/webkit/WebViewRenderProcessClient` object associated with this WebView, if one has been set via `https://developer.android.com/reference/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/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/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")
public static boolean isAudioMuted(@NonNull WebView webView)
```

Returns whether this WebView is muted.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView for which to check mute status. |

| Returns |
|---|---|
| `boolean` | 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/androidx/webkit/WebViewFeature#MUTE_AUDIO()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static boolean isMultiProcessEnabled()
```

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/androidx/webkit/WebViewFeature#MULTI_PROCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static @NonNull Navigation navigate(
    @NonNull WebView webview,
    @NonNull String url,
    @NonNull NavigationParameters params
)
```

Navigates the provided WebView to the given url, with configuration provided by `https://developer.android.com/reference/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/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/androidx/webkit/WebViewFeature#WEBVIEW_NAVIGATE_DRAIN_PREFETCH()` feature is supported. This can be checked using `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The WebView to perform the navigation on. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url` | The URL to load. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/NavigationParameters params` | The navigation parameters. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#WEBVIEW_NAVIGATE_EXPERIMENTAL_V1()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void postVisualStateCallback(
    @NonNull WebView webview,
    long requestId,
    @NonNull WebViewCompat.VisualStateCallback callback
)
```

Posts a `https://developer.android.com/reference/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/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/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/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/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/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The WebView to post to. |
| `long requestId` | An id that will be returned in the callback to allow callers to match requests with callbacks. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewCompat.VisualStateCallback callback` | The callback to be invoked. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#VISUAL_STATE_CALLBACK()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void postWebMessage(
    @NonNull WebView webview,
    @NonNull WebMessageCompat message,
    @NonNull Uri targetOrigin
)
```

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/androidx/webkit/WebMessageCompat` with type `https://developer.android.com/reference/androidx/webkit/WebMessageCompat#TYPE_ARRAY_BUFFER()`, this method should check if `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns true for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#WEB_MESSAGE_ARRAY_BUFFER()`. Example:

```
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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The WebView to post to. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebMessageCompat message` | the WebMessage |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html targetOrigin` | the target origin. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#POST_WEB_MESSAGE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static void prerenderUrlAsync(
    @NonNull WebView webView,
    @NonNull String url,
    @Nullable CancellationSignal cancellationSignal,
    @NonNull Executor callbackExecutor,
    @NonNull PrerenderOperationCallback callback
)
```

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/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView for which we trigger the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url` | the url associated with the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | used to trigger prerender cancellation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | the executor to resolve the callback with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/PrerenderOperationCallback callback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static void prerenderUrlAsync(
    @NonNull WebView webView,
    @NonNull String url,
    @Nullable CancellationSignal cancellationSignal,
    @NonNull Executor callbackExecutor,
    @NonNull PrerenderParameters params,
    @NonNull PrerenderOperationCallback callback
)
```

The same as `https://developer.android.com/reference/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/androidx/webkit/PrerenderParameters`.

When `https://developer.android.com/reference/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/androidx/webkit/PrerenderParameters` for more details on how to configure the matching algorithm.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView for which we trigger the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url` | the url associated with the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | used to trigger prerender cancellation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | the executor to resolve the callback with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/PrerenderParameters params` | parameters to customize the prerender request and its matching behavior. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/PrerenderOperationCallback callback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static void [prerenderUrlAsync](https://developer.android.com/reference/androidx/webkit/WebViewCompat#prerenderUrlAsync(android.webkit.WebView,java.lang.String,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.webkit.SpeculativeLoadingParameters,androidx.webkit.PrerenderOperationCallback))(
    @NonNull WebView webView,
    @NonNull String url,
    @Nullable CancellationSignal cancellationSignal,
    @NonNull Executor callbackExecutor,
    @NonNull SpeculativeLoadingParameters params,
    @NonNull PrerenderOperationCallback callback
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/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/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/androidx/webkit/SpeculativeLoadingParameters`.

When `https://developer.android.com/reference/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/androidx/webkit/SpeculativeLoadingParameters` for more details on how to configure the matching algorithm.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView for which we trigger the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url` | the url associated with the prerender request. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | used to trigger prerender cancellation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | the executor to resolve the callback with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/SpeculativeLoadingParameters params` | parameters to customize the prerender request and its matching behavior. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/PrerenderOperationCallback callback` | callbacks for reporting result back to application. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#PRERENDER_WITH_URL()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static void removeNavigationListener(
    @NonNull WebView webView,
    @NonNull NavigationListener listener
)
```

Removes a `https://developer.android.com/reference/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/androidx/webkit/WebViewCompat#addNavigationListener(android.webkit.WebView,java.util.concurrent.Executor,androidx.webkit.NavigationListener)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | The `https://developer.android.com/reference/android/webkit/WebView.html` to set the client for. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/NavigationListener listener` | The `https://developer.android.com/reference/androidx/webkit/NavigationListener` to remove. |

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

| See also |
|---|---|
| `https://developer.android.com/reference/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")
public static void removeWebMessageListener(
    @NonNull WebView webview,
    @NonNull String jsObjectName
)
```

Removes the `https://developer.android.com/reference/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/androidx/webkit/WebViewCompat.WebMessageListener`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The WebView object to remove from. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html jsObjectName` | The JavaScript object's name that was previously passed to `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#WEB_MESSAGE_LISTENER()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/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")
public static void removeWebMessageListener(
    @NonNull WebView webview,
    @NonNull JavaScriptExecutionWorld world,
    @NonNull String jsObjectName
)
```

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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#JS_INJECTION_IN_FRAME_AND_WORLD()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | The `https://developer.android.com/reference/android/webkit/WebView.html` instance that we are interacting with. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/JavaScriptExecutionWorld world` | The execution world from which to remove the listener. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html jsObjectName` | 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/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/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
public static void saveState(
    @NonNull WebView webView,
    @NonNull Bundle outState,
    @IntRange(from = 1) int maxSizeBytes,
    boolean includeForwardState
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the `https://developer.android.com/reference/android/webkit/WebView.html` whose state is to be saved. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html outState` | the `https://developer.android.com/reference/android/os/Bundle.html` to store the state in. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int maxSizeBytes` | 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. |
| `boolean includeForwardState` | 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/androidx/webkit/WebViewFeature#SAVE_STATE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void setAudioMuted(@NonNull WebView webView, boolean mute)
```

Mute or un-mute this WebView.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView for which to control muting. |
| `boolean mute` | 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/androidx/webkit/WebViewFeature#MUTE_AUDIO()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void setDefaultTrafficStatsTag(int tag)
```

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 |
|---|---|
| `int tag` | 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/androidx/webkit/WebViewFeature#DEFAULT_TRAFFICSTATS_TAGGING()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void setProfile(@NonNull WebView webView, @NonNull String profileName)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webView` | the WebView to modify. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html profileName` | 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/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/androidx/webkit/WebViewFeature#MULTI_PROFILE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void setSafeBrowsingAllowlist(
    @NonNull Set<String> hosts,
    @Nullable ValueCallback<Boolean> callback
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> hosts` | the set of hosts for which to skip Safe Browsing checks |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/webkit/ValueCallback.html<https://developer.android.com/reference/java/lang/Boolean.html> callback` | 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/androidx/webkit/WebViewFeature#SAFE_BROWSING_ALLOWLIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void [setSafeBrowsingWhitelist](https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingWhitelist(java.util.List<java.lang.String>,android.webkit.ValueCallback<java.lang.Boolean>))(
    @NonNull List<String> hosts,
    @Nullable ValueCallback<Boolean> callback
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Please use `https://developer.android.com/reference/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html> hosts` | the list of hosts |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/webkit/ValueCallback.html<https://developer.android.com/reference/java/lang/Boolean.html> callback` | 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/androidx/webkit/WebViewFeature#SAFE_BROWSING_WHITELIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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")
public static void setWebViewRenderProcessClient(
    @NonNull WebView webview,
    @Nullable WebViewRenderProcessClient webViewRenderProcessClient
)
```

Sets the renderer client object associated with this WebView.

See `https://developer.android.com/reference/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/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/androidx/webkit/WebViewFeature#WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | the `https://developer.android.com/reference/android/webkit/WebView.html` on which to monitor responsiveness. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/webkit/WebViewRenderProcessClient webViewRenderProcessClient` | the `https://developer.android.com/reference/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")
public static void setWebViewRenderProcessClient(
    @NonNull WebView webview,
    @NonNull Executor executor,
    @NonNull WebViewRenderProcessClient webViewRenderProcessClient
)
```

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/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/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/WebView.html webview` | the `https://developer.android.com/reference/android/webkit/WebView.html` on which to monitor responsiveness. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | the `https://developer.android.com/reference/java/util/concurrent/Executor.html` that will be used to execute callbacks. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewRenderProcessClient webViewRenderProcessClient` | the `https://developer.android.com/reference/androidx/webkit/WebViewRenderProcessClient` to set for callbacks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/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/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")
public static void [startSafeBrowsing](https://developer.android.com/reference/androidx/webkit/WebViewCompat#startSafeBrowsing(android.content.Context,android.webkit.ValueCallback<java.lang.Boolean>))(
    @NonNull Context context,
    @Nullable ValueCallback<Boolean> callback
)
```

> [!CAUTION]
> **This method 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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Application Context. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/webkit/ValueCallback.html<https://developer.android.com/reference/java/lang/Boolean.html> callback` | 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/androidx/webkit/WebViewFeature#START_SAFE_BROWSING()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/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
public static void [startUpWebView](https://developer.android.com/reference/androidx/webkit/WebViewCompat#startUpWebView(android.content.Context,androidx.webkit.WebViewStartUpConfig,androidx.webkit.WebViewCompat.WebViewStartUpCallback))(
    @NonNull Context context,
    @NonNull WebViewStartUpConfig config,
    @NonNull WebViewCompat.WebViewStartUpCallback callback
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This is an experimental version and is planned to be removed in the next release. Use `https://developer.android.com/reference/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/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/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Application Context. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewStartUpConfig config` | configuration for startup. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebViewStartUpCallback callback` | 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
public static void startUpWebView(
    @NonNull Context context,
    @NonNull WebViewStartUpConfig config,
    @NonNull WebViewOutcomeReceiver<WebViewStartUpResult, WebViewStartupException> callback
)
```

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/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/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/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/androidx/webkit/WebViewStartUpConfig#getBackgroundExecutor()` is only used by WebView to run background startup tasks, not to invoke `callback`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Application Context. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewStartUpConfig config` | configuration for startup. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/webkit/WebViewOutcomeReceiver<https://developer.android.com/reference/androidx/webkit/WebViewStartUpResult, https://developer.android.com/reference/androidx/webkit/WebViewStartupException> callback` | 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/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
public static void startUpWebView(
    @NonNull Context context,
    @NonNull WebViewStartUpConfig config,
    @NonNull Executor callbackExecutor,
    @NonNull WebViewOutcomeReceiver<WebViewStartUpResult, WebViewStartupException> callback
)
```

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

This method functions as `https://developer.android.com/reference/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/androidx/webkit/WebViewStartUpConfig#getBackgroundExecutor()` is used by WebView to run background startup tasks.

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

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