Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

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

Public methods
open static Boolean
isFeatureSupported(@NonNull feature: String)

Return whether a feature is supported at run-time.

Constants

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: Features.VISUAL_STATE_CALLBACK

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: Features.OFF_SCREEN_PRERASTER

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: Features.SAFE_BROWSING_ENABLE

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: Features.DISABLED_ACTION_MODE_MENU_ITEMS

START_SAFE_BROWSING

static val START_SAFE_BROWSING: String

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

Value: Features.START_SAFE_BROWSING

SAFE_BROWSING_WHITELIST

static val SAFE_BROWSING_WHITELIST: String

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

Value: Features.SAFE_BROWSING_WHITELIST

SAFE_BROWSING_PRIVACY_POLICY_URL

static val SAFE_BROWSING_PRIVACY_POLICY_URL: String

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

Value: Features.SAFE_BROWSING_PRIVACY_POLICY_URL

SERVICE_WORKER_BASIC_USAGE

static val SERVICE_WORKER_BASIC_USAGE: String

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

Value: Features.SERVICE_WORKER_BASIC_USAGE

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: Features.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: Features.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: Features.SERVICE_WORKER_FILE_ACCESS

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: Features.SERVICE_WORKER_BLOCK_NETWORK_LOADS

SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

static val SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST: String

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

Value: Features.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

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: Features.RECEIVE_WEB_RESOURCE_ERROR

RECEIVE_HTTP_ERROR

static val RECEIVE_HTTP_ERROR: String

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

Value: Features.RECEIVE_HTTP_ERROR

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: Features.SHOULD_OVERRIDE_WITH_REDIRECTS

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: Features.SAFE_BROWSING_HIT

WEB_RESOURCE_REQUEST_IS_REDIRECT

static val WEB_RESOURCE_REQUEST_IS_REDIRECT: String

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

Value: Features.WEB_RESOURCE_REQUEST_IS_REDIRECT

WEB_RESOURCE_ERROR_GET_DESCRIPTION

static val WEB_RESOURCE_ERROR_GET_DESCRIPTION: String

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

Value: Features.WEB_RESOURCE_ERROR_GET_DESCRIPTION

WEB_RESOURCE_ERROR_GET_CODE

static val WEB_RESOURCE_ERROR_GET_CODE: String

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

Value: Features.WEB_RESOURCE_ERROR_GET_CODE

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: Features.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: Features.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: Features.SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL

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: Features.WEB_MESSAGE_PORT_POST_MESSAGE

WEB_MESSAGE_PORT_CLOSE

static val WEB_MESSAGE_PORT_CLOSE: String

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

Value: Features.WEB_MESSAGE_PORT_CLOSE

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: Features.WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK

CREATE_WEB_MESSAGE_CHANNEL

static val CREATE_WEB_MESSAGE_CHANNEL: String

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

Value: Features.CREATE_WEB_MESSAGE_CHANNEL

POST_WEB_MESSAGE

static val POST_WEB_MESSAGE: String

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

Value: Features.POST_WEB_MESSAGE

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: Features.WEB_MESSAGE_CALLBACK_ON_MESSAGE

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