androidx.webkit
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); }
Annotations
Profile.ExperimentalUrlPrefetch |
Denotes that the UrlPrefetch API surface is experimental. |
WebSettingsCompat.ExperimentalBackForwardCache |
Denotes that the BackForwardCache API surface is experimental. |
WebSettingsCompat.ExperimentalSpeculativeLoading |
Denotes that the SpeculativeLoading API surface is experimental. |
WebViewCompat.ExperimentalAsyncStartUp |
Denotes that the startUpWebView API surface is experimental. |
Interfaces
PrefetchOperationCallback |
Callback interface for prefetch operations. |
Profile |
A Profile represents one browsing session for WebView. |
ProfileStore |
Manages any creation, deletion for |
ScriptHandler |
This interface represents the return result from |
WebViewAssetLoader.PathHandler |
A handler that produces responses for a registered path. |
WebViewCompat.VisualStateCallback |
Callback interface supplied to |
WebViewCompat.WebMessageListener |
This listener receives messages sent on the JavaScript object which was injected by |
WebViewCompat.WebViewStartUpCallback |
Callback interface for |
WebViewStartUpResult |
Result object associated with |
Classes
CookieManagerCompat |
Compatibility version of |
DropDataContentProvider |
WebView provides partial support for Android Drag and Drop allowing images, text and links to be dragged out of a WebView. |
JavaScriptReplyProxy |
This class represents the JavaScript object injected by |
NoVarySearchData |
The No-Vary-Search data specifies a set of rules that define how a URL's query parameters will affect cache matching. |
PrefetchParameters |
Parameters for customizing the prefetch. |
PrefetchParameters.Builder |
A builder class to use to construct the |
ProcessGlobalConfig |
Process Global Configuration for WebView. |
ProxyConfig |
Config for |
ProxyConfig.Builder |
ProxyConfig builder. |
ProxyConfig.ProxyRule |
Class that holds a scheme filter and a proxy URL. |
ProxyController |
Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by |
SafeBrowsingResponseCompat |
Compatibility version of |
ServiceWorkerClientCompat |
Base class for clients to capture Service Worker related callbacks, see |
ServiceWorkerControllerCompat |
Manages Service Workers used by WebView. |
ServiceWorkerWebSettingsCompat |
Manages settings state for all Service Workers. |
TracingConfig |
Holds tracing configuration information and predefined settings for |
TracingConfig.Builder |
Builder used to create |
TracingController |
Manages tracing of WebViews. |
URLUtilCompat |
Compatibility versions of methods in |
UserAgentMetadata |
Holds user-agent metadata information and uses to generate user-agent client hints. |
UserAgentMetadata.BrandVersion |
Class that holds brand name, major version and full version. |
UserAgentMetadata.BrandVersion.Builder |
Builder used to create |
UserAgentMetadata.Builder |
Builder used to create |
WebMessageCompat |
The Java representation of the HTML5 PostMessage event. |
WebMessagePortCompat |
The Java representation of the HTML5 message ports. |
WebMessagePortCompat.WebMessageCallbackCompat |
The listener for handling MessagePort events. |
WebResourceErrorCompat |
Compatibility version of |
WebResourceRequestCompat |
Compatibility version of |
WebSettingsCompat |
Compatibility version of |
WebViewAssetLoader |
Helper class to load local files including application's static assets and resources using http(s):// URLs inside a |
WebViewAssetLoader.AssetsPathHandler |
Handler class to open a file from assets directory in the application APK. |
WebViewAssetLoader.Builder |
A builder class for constructing |
WebViewAssetLoader.InternalStoragePathHandler |
Handler class to open files from application internal storage. |
WebViewAssetLoader.ResourcesPathHandler |
Handler class to open a file from resources directory in the application APK. |
WebViewClientCompat |
Compatibility version of |
WebViewCompat |
Compatibility version of |
WebViewFeature |
Utility class for checking which WebView Support Library features are supported on the device. |
WebViewMediaIntegrityApiStatusConfig |
Configuration to set API enablement status for site origins through override rules. |
WebViewMediaIntegrityApiStatusConfig.Builder |
Builds a |
WebViewRenderProcess |
WebViewRenderProcess provides an opaque handle to a WebView renderer. |
WebViewRenderProcessClient |
Used to receive callbacks on |
WebViewStartUpConfig |
Configuration object for |
WebViewStartUpConfig.Builder |
Exceptions
PrefetchException |
Super class for all asynchronous exceptions produced by |