Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

WebViewFeature

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

Utility class for checking which WebView Support Library features are supported on the device.

Summary

Constants

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

static String

i* Feature for isFeatureSupported(String).

static String

Feature for isFeatureSupported(String).

Public methods

open static Boolean
isFeatureSupported(@NonNull feature: String)

Return whether a feature is supported at run-time.

Constants

CREATE_WEB_MESSAGE_CHANNEL

static val CREATE_WEB_MESSAGE_CHANNEL: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#createWebMessageChannel(WebView).

Value: "CREATE_WEB_MESSAGE_CHANNEL"

DISABLED_ACTION_MODE_MENU_ITEMS

static val DISABLED_ACTION_MODE_MENU_ITEMS: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebSettingsCompat#getDisabledActionModeMenuItems(WebSettings), and androidx.webkit.WebSettingsCompat#setDisabledActionModeMenuItems(WebSettings, int).

Value: "DISABLED_ACTION_MODE_MENU_ITEMS"

GET_WEB_CHROME_CLIENT

static val GET_WEB_CHROME_CLIENT: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#getWebChromeClient(WebView)

Value: "GET_WEB_CHROME_CLIENT"

GET_WEB_VIEW_CLIENT

static val GET_WEB_VIEW_CLIENT: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#getWebViewClient(WebView)

Value: "GET_WEB_VIEW_CLIENT"

GET_WEB_VIEW_RENDERER

static val GET_WEB_VIEW_RENDERER: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#getWebViewRenderProcess(WebView)

Value: "GET_WEB_VIEW_RENDERER"

OFF_SCREEN_PRERASTER

static val OFF_SCREEN_PRERASTER: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebSettingsCompat#getOffscreenPreRaster(WebSettings), and androidx.webkit.WebSettingsCompat#setOffscreenPreRaster(WebSettings, boolean).

Value: "OFF_SCREEN_PRERASTER"

POST_WEB_MESSAGE

static val POST_WEB_MESSAGE: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#postWebMessage(WebView, WebMessageCompat, Uri).

Value: "POST_WEB_MESSAGE"

PROXY_OVERRIDE

static val PROXY_OVERRIDE: String

Feature for isFeatureSupported(String). This feature covers ProxyController#setProxyOverride(ProxyConfig, Executor, Runnable), ProxyController#clearProxyOverride(Executor, Runnable), and

Value: "PROXY_OVERRIDE"

RECEIVE_HTTP_ERROR

static val RECEIVE_HTTP_ERROR: String

Feature for isFeatureSupported(String). This feature covers WebViewClientCompat#onReceivedHttpError(android.webkit.WebView, WebResourceRequest, * WebResourceResponse).

Value: "RECEIVE_HTTP_ERROR"

RECEIVE_WEB_RESOURCE_ERROR

static val RECEIVE_WEB_RESOURCE_ERROR: String

Feature for isFeatureSupported(String). This feature covers WebViewClientCompat#onReceivedError(android.webkit.WebView, WebResourceRequest, * WebResourceErrorCompat).

Value: "RECEIVE_WEB_RESOURCE_ERROR"

SAFE_BROWSING_ENABLE

static val SAFE_BROWSING_ENABLE: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebSettingsCompat#getSafeBrowsingEnabled(WebSettings), and androidx.webkit.WebSettingsCompat#setSafeBrowsingEnabled(WebSettings, boolean).

Value: "SAFE_BROWSING_ENABLE"

SAFE_BROWSING_HIT

static val SAFE_BROWSING_HIT: String

Feature for isFeatureSupported(String). This feature covers WebViewClientCompat#onSafeBrowsingHit(android.webkit.WebView, * WebResourceRequest, int, SafeBrowsingResponseCompat).

Value: "SAFE_BROWSING_HIT"

SAFE_BROWSING_PRIVACY_POLICY_URL

static val SAFE_BROWSING_PRIVACY_POLICY_URL: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#getSafeBrowsingPrivacyPolicyUrl().

Value: "SAFE_BROWSING_PRIVACY_POLICY_URL"

SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY

static val SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY: String

Feature for isFeatureSupported(String). This feature covers SafeBrowsingResponseCompat#backToSafety(boolean).

Value: "SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"

SAFE_BROWSING_RESPONSE_PROCEED

static val SAFE_BROWSING_RESPONSE_PROCEED: String

Feature for isFeatureSupported(String). This feature covers SafeBrowsingResponseCompat#proceed(boolean).

Value: "SAFE_BROWSING_RESPONSE_PROCEED"

SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL

static val SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL: String

Feature for isFeatureSupported(String). This feature covers SafeBrowsingResponseCompat#showInterstitial(boolean).

Value: "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"

SAFE_BROWSING_WHITELIST

static val SAFE_BROWSING_WHITELIST: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#setSafeBrowsingWhitelist(List, ValueCallback).

Value: "SAFE_BROWSING_WHITELIST"

SERVICE_WORKER_BASIC_USAGE

static val SERVICE_WORKER_BASIC_USAGE: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerControllerCompat#getInstance().

Value: "SERVICE_WORKER_BASIC_USAGE"

SERVICE_WORKER_BLOCK_NETWORK_LOADS

static val SERVICE_WORKER_BLOCK_NETWORK_LOADS: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerWebSettingsCompat#getBlockNetworkLoads(), and ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean).

Value: "SERVICE_WORKER_BLOCK_NETWORK_LOADS"

SERVICE_WORKER_CACHE_MODE

static val SERVICE_WORKER_CACHE_MODE: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerWebSettingsCompat#getCacheMode(), and ServiceWorkerWebSettingsCompat#setCacheMode(int).

Value: "SERVICE_WORKER_CACHE_MODE"

SERVICE_WORKER_CONTENT_ACCESS

static val SERVICE_WORKER_CONTENT_ACCESS: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerWebSettingsCompat#getAllowContentAccess(), and ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean).

Value: "SERVICE_WORKER_CONTENT_ACCESS"

SERVICE_WORKER_FILE_ACCESS

static val SERVICE_WORKER_FILE_ACCESS: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerWebSettingsCompat#getAllowFileAccess(), and ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean).

Value: "SERVICE_WORKER_FILE_ACCESS"

SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

static val SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST: String

Feature for isFeatureSupported(String). This feature covers ServiceWorkerClientCompat#shouldInterceptRequest(WebResourceRequest).

Value: "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"

SHOULD_OVERRIDE_WITH_REDIRECTS

static val SHOULD_OVERRIDE_WITH_REDIRECTS: String

Feature for isFeatureSupported(String). This feature covers WebViewClientCompat#shouldOverrideUrlLoading(android.webkit.WebView, * WebResourceRequest).

Value: "SHOULD_OVERRIDE_WITH_REDIRECTS"

START_SAFE_BROWSING

static val START_SAFE_BROWSING: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#startSafeBrowsing(Context, ValueCallback).

Value: "START_SAFE_BROWSING"

TRACING_CONTROLLER_BASIC_USAGE

static val TRACING_CONTROLLER_BASIC_USAGE: String

Feature for isFeatureSupported(String). This feature covers TracingController#getInstance(), TracingController#isTracing(), TracingController#start(TracingConfig), TracingController#stop(OutputStream, Executor).

Value: "TRACING_CONTROLLER_BASIC_USAGE"

VISUAL_STATE_CALLBACK

static val VISUAL_STATE_CALLBACK: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#postVisualStateCallback(android.webkit.WebView, long, * WebViewCompat.VisualStateCallback), and .

Value: "VISUAL_STATE_CALLBACK"

WEB_MESSAGE_CALLBACK_ON_MESSAGE

static val WEB_MESSAGE_CALLBACK_ON_MESSAGE: String

Feature for isFeatureSupported(String). This feature covers WebMessagePortCompat.WebMessageCallbackCompat#onMessage(WebMessagePortCompat, * WebMessageCompat).

Value: "WEB_MESSAGE_CALLBACK_ON_MESSAGE"

WEB_MESSAGE_PORT_CLOSE

static val WEB_MESSAGE_PORT_CLOSE: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebMessagePortCompat#close().

Value: "WEB_MESSAGE_PORT_CLOSE"

WEB_MESSAGE_PORT_POST_MESSAGE

static val WEB_MESSAGE_PORT_POST_MESSAGE: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebMessagePortCompat#postMessage(WebMessageCompat).

Value: "WEB_MESSAGE_PORT_POST_MESSAGE"

WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK

static val WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK: String

Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebMessagePortCompat#setWebMessageCallback( * WebMessagePortCompat.WebMessageCallbackCompat), and androidx.webkit.WebMessagePortCompat#setWebMessageCallback(Handler, * WebMessagePortCompat.WebMessageCallbackCompat).

Value: "WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"

WEB_RESOURCE_ERROR_GET_CODE

static val WEB_RESOURCE_ERROR_GET_CODE: String

Feature for isFeatureSupported(String). This feature covers WebResourceErrorCompat#getErrorCode().

Value: "WEB_RESOURCE_ERROR_GET_CODE"

WEB_RESOURCE_ERROR_GET_DESCRIPTION

static val WEB_RESOURCE_ERROR_GET_DESCRIPTION: String

Feature for isFeatureSupported(String). This feature covers WebResourceErrorCompat#getDescription().

Value: "WEB_RESOURCE_ERROR_GET_DESCRIPTION"

WEB_RESOURCE_REQUEST_IS_REDIRECT

static val WEB_RESOURCE_REQUEST_IS_REDIRECT: String

Feature for isFeatureSupported(String). This feature covers WebResourceRequestCompat#isRedirect(WebResourceRequest).

Value: "WEB_RESOURCE_REQUEST_IS_REDIRECT"

WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE

static val WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE: String

i* Feature for isFeatureSupported(String). This feature covers androidx.webkit.WebViewCompat#getWebViewRenderProcessClient(WebView), androidx.webkit.WebViewCompat#setWebViewRenderProcessClient(WebView, WebViewRenderProcessClient),

Value: "WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"

WEB_VIEW_RENDERER_TERMINATE

static val WEB_VIEW_RENDERER_TERMINATE: String

Feature for isFeatureSupported(String). This feature covers WebViewRenderProcess#terminate()

Value: "WEB_VIEW_RENDERER_TERMINATE"

Public methods

isFeatureSupported

open static fun isFeatureSupported(@NonNull feature: String): Boolean

Return whether a feature is supported at run-time. On devices running Android version and higher, this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, and the WebView APK on the device. If running on a device with a lower API level, this will always return false.

Note: If this method returns false, it is not safe to invoke the methods requiring the desired feature. Furthermore, if this method returns false for a particular feature, any callback guarded by that feature will not be invoked.

Parameters
feature String: the feature to be checked
Return
Boolean: whether the feature is supported given the current platform SDK and webview version