package

androidx.webkit

Overview

The androidx.webkit library is a static library you can add to your Android application in order to use android.webkit APIs that are not available for older platform versions.

Requirements

The minimum sdk version to use this library is 14.

How to declare the dependencies to use the library

Please check the release notes for instructions to add the latest release to your build.gradle file.

Public bug tracker

If you find bugs in the androidx.webkit library or want to request new features, please do so here.

Sample apps

Please check out the WebView samples on GitHub for a showcase of a handful of androidx.webkit APIs.

For more APIs, check out the sample app in the AndroidX repo.

Migrating to androidx.webkit

For static methods:

Old code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
    WebView.startSafeBrowsing(appContext, callback);
}

New code:

if (WebViewFeature.isFeatureSupported(WebViewFeature.START_SAFE_BROWSING)) {
    WebViewCompat.startSafeBrowsing(appContext, callback);
}

Or, if you are using a non-static method:

Old code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    myWebView.postVisualStateCallback(requestId, callback);
}

New code:

if (WebViewFeature.isFeatureSupported(WebViewFeature.VISUAL_STATE_CALLBACK)) {
    WebViewCompat.postVisualStateCallback(myWebView, requestId, callback);
}

Interfaces

ProfileA Profile represents one browsing session for WebView.
ProfileStoreManages any creation, deletion for Profile.
ScriptHandlerThis interface represents the return result from WebViewCompat.
WebViewAssetLoader.PathHandlerA handler that produces responses for a registered path.
WebViewCompat.VisualStateCallbackCallback interface supplied to WebViewCompat.postVisualStateCallback(WebView, long, WebViewCompat.VisualStateCallback) for receiving notifications about the visual state.
WebViewCompat.WebMessageListenerThis listener receives messages sent on the JavaScript object which was injected by WebViewCompat.addWebMessageListener(WebView, String, Set, WebViewCompat.WebMessageListener).

Classes

CookieManagerCompatCompatibility version of
DropDataContentProviderWebView provides partial support for Android Drag and Drop allowing images, text and links to be dragged out of a WebView.
JavaScriptReplyProxyThis class represents the JavaScript object injected by WebViewCompat#addWebMessageListener.
ProcessGlobalConfigProcess Global Configuration for WebView.
ProxyConfigConfig for ProxyController.setProxyOverride(ProxyConfig, Executor, Runnable).
ProxyConfig.BuilderProxyConfig builder.
ProxyConfig.ProxyRuleClass that holds a scheme filter and a proxy URL.
ProxyControllerManages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by .
SafeBrowsingResponseCompatCompatibility version of .
ScriptReferenceCompatTODO(ctzsm): Complete Javadoc
ServiceWorkerClientCompatBase class for clients to capture Service Worker related callbacks, see ServiceWorkerControllerCompat for usage example.
ServiceWorkerControllerCompatManages Service Workers used by WebView.
ServiceWorkerWebSettingsCompatManages settings state for all Service Workers.
TracingConfigHolds tracing configuration information and predefined settings for TracingController.
TracingConfig.BuilderBuilder used to create TracingConfig objects.
TracingControllerManages tracing of WebViews.
URLUtilCompatCompatibility versions of methods in .
UserAgentMetadataHolds user-agent metadata information and uses to generate user-agent client hints.
UserAgentMetadata.BrandVersionClass that holds brand name, major version and full version.
UserAgentMetadata.BrandVersion.BuilderBuilder used to create UserAgentMetadata.BrandVersion objects.
UserAgentMetadata.BuilderBuilder used to create UserAgentMetadata objects.
WebMessageCompatThe Java representation of the HTML5 PostMessage event.
WebMessagePortCompat

The Java representation of the HTML5 message ports.

WebMessagePortCompat.WebMessageCallbackCompatThe listener for handling MessagePort events.
WebResourceErrorCompatCompatibility version of .
WebResourceRequestCompatCompatibility version of .
WebSettingsCompatCompatibility version of
WebViewAssetLoaderHelper class to load local files including application's static assets and resources using http(s):// URLs inside a class.
WebViewAssetLoader.AssetsPathHandlerHandler class to open a file from assets directory in the application APK.
WebViewAssetLoader.BuilderA builder class for constructing WebViewAssetLoader objects.
WebViewAssetLoader.InternalStoragePathHandlerHandler class to open files from application internal storage.
WebViewAssetLoader.ResourcesPathHandlerHandler class to open a file from resources directory in the application APK.
WebViewClientCompatCompatibility version of .
WebViewCompatCompatibility version of
WebViewFeatureUtility class for checking which WebView Support Library features are supported on the device.
WebViewMediaIntegrityApiStatusConfigConfiguration to set API enablement status for site origins through override rules.
WebViewMediaIntegrityApiStatusConfig.BuilderBuilds a WebViewMediaIntegrityApiStatusConfig having a default API status and a map of origin pattern rules to their respective API status.
WebViewRenderProcessWebViewRenderProcess provides an opaque handle to a WebView renderer.
WebViewRenderProcessClientUsed to receive callbacks on renderer events.

Annotation Types

ProxyConfig.ProxyScheme
ServiceWorkerWebSettingsCompat.CacheMode
TracingConfig.PredefinedCategories
TracingConfig.TracingMode
WebMessageCompat.Type
WebResourceErrorCompat.NetErrorCode
WebSettingsCompat.ForceDark
WebSettingsCompat.ForceDarkStrategy
WebSettingsCompat.MenuItemFlags
WebViewClientCompat.SafeBrowsingThreat
WebViewFeature.WebViewStartupFeature
WebViewFeature.WebViewSupportFeature