Android 12 Developer Preview is here! Try it out, and give us your feedback!

WebViewCompat

open class WebViewCompat
kotlin.Any
   ↳ androidx.webkit.WebViewCompat

Compatibility version of android.webkit.WebView

Summary

Nested classes
abstract

Callback interface supplied to postVisualStateCallback for receiving notifications about the visual state.

abstract

This listener receives messages sent on the JavaScript object which was injected by .

Public methods
open static Unit
addWebMessageListener(@NonNull webView: WebView, @NonNull jsObjectName: String, @NonNull allowedOriginRules: MutableSet<String!>, @NonNull listener: WebViewCompat.WebMessageListener)

Adds a WebMessageListener to the WebView and injects a JavaScript object into each frame that the WebMessageListener will listen on.

open static Array<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.

open static 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.

open static Uri

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

open static WebChromeClient?
getWebChromeClient(@NonNull webview: WebView)

Gets the WebChromeClient.

open static WebViewClient
getWebViewClient(@NonNull webview: WebView)

Gets the WebViewClient for the WebView argument.

open static WebViewRenderProcess?
getWebViewRenderProcess(@NonNull webview: WebView)

Gets the WebView renderer associated with this WebView.

open static WebViewRenderProcessClient?

Gets the renderer client object associated with this WebView.

open static Boolean

Returns true if WebView is running in multi process mode.

open static Unit
postVisualStateCallback(@NonNull webview: WebView, requestId: Long, @NonNull callback: WebViewCompat.VisualStateCallback)

Posts a VisualStateCallback, which will be called when the current state of the WebView is ready to be drawn.

open static Unit
postWebMessage(@NonNull webview: WebView, @NonNull message: WebMessageCompat, @NonNull targetOrigin: Uri)

Post a message to main frame.

open static Unit
removeWebMessageListener(@NonNull webview: WebView, @NonNull jsObjectName: String)

Removes the WebMessageListener associated with jsObjectName.

open static Unit
setSafeBrowsingAllowlist(@NonNull hosts: MutableSet<String!>, @Nullable callback: ValueCallback<Boolean!>?)

Configures a set of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks.

open static Unit
setSafeBrowsingWhitelist(@NonNull hosts: MutableList<String!>, @Nullable callback: ValueCallback<Boolean!>?)

Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks.

open static Unit
setWebViewRenderProcessClient(@NonNull webview: WebView, @NonNull executor: Executor, @NonNull webViewRenderProcessClient: WebViewRenderProcessClient)

Sets the renderer client object associated with this WebView.

open static Unit
setWebViewRenderProcessClient(@NonNull webview: WebView, @Nullable webViewRenderProcessClient: WebViewRenderProcessClient?)

Sets the renderer client object associated with this WebView.

open static