Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.webkit:webkit:1.1.0-alpha01

WebViewFeature

public class WebViewFeature
extends Object

java.lang.Object
   ↳ androidx.webkit.WebViewFeature


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

Summary

Constants

String CREATE_WEB_MESSAGE_CHANNEL

Feature for isFeatureSupported(String).

String DISABLED_ACTION_MODE_MENU_ITEMS

Feature for isFeatureSupported(String).

String OFF_SCREEN_PRERASTER

Feature for isFeatureSupported(String).

String POST_WEB_MESSAGE

Feature for isFeatureSupported(String).

String RECEIVE_HTTP_ERROR

Feature for isFeatureSupported(String).

String RECEIVE_WEB_RESOURCE_ERROR

Feature for isFeatureSupported(String).

String SAFE_BROWSING_ENABLE

Feature for isFeatureSupported(String).

String SAFE_BROWSING_HIT

Feature for isFeatureSupported(String).

String SAFE_BROWSING_PRIVACY_POLICY_URL

Feature for isFeatureSupported(String).

String SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY

Feature for isFeatureSupported(String).

String SAFE_BROWSING_RESPONSE_PROCEED

Feature for isFeatureSupported(String).

String SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL

Feature for isFeatureSupported(String).

String SAFE_BROWSING_WHITELIST

Feature for isFeatureSupported(String).

String SERVICE_WORKER_BASIC_USAGE

Feature for isFeatureSupported(String).

String SERVICE_WORKER_BLOCK_NETWORK_LOADS

Feature for isFeatureSupported(String).

String SERVICE_WORKER_CACHE_MODE

Feature for isFeatureSupported(String).

String SERVICE_WORKER_CONTENT_ACCESS

Feature for isFeatureSupported(String).

String SERVICE_WORKER_FILE_ACCESS

Feature for isFeatureSupported(String).

String SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

Feature for isFeatureSupported(String).

String SHOULD_OVERRIDE_WITH_REDIRECTS

Feature for isFeatureSupported(String).

String START_SAFE_BROWSING

Feature for isFeatureSupported(String).

String VISUAL_STATE_CALLBACK

Feature for isFeatureSupported(String).

String WEB_MESSAGE_CALLBACK_ON_MESSAGE

Feature for isFeatureSupported(String).

String WEB_MESSAGE_PORT_CLOSE

Feature for isFeatureSupported(String).

String WEB_MESSAGE_PORT_POST_MESSAGE

Feature for isFeatureSupported(String).

String WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK

Feature for isFeatureSupported(String).

String WEB_RESOURCE_ERROR_GET_CODE

Feature for isFeatureSupported(String).

String WEB_RESOURCE_ERROR_GET_DESCRIPTION

Feature for isFeatureSupported(String).

String WEB_RESOURCE_REQUEST_IS_REDIRECT

Feature for isFeatureSupported(String).

Public methods

static boolean isFeatureSupported(String feature)

Return whether a feature is supported at run-time.

Inherited methods

Constants

CREATE_WEB_MESSAGE_CHANNEL

added in version 1.0.0
public static final String CREATE_WEB_MESSAGE_CHANNEL

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

Constant Value: "CREATE_WEB_MESSAGE_CHANNEL"

DISABLED_ACTION_MODE_MENU_ITEMS

added in version 1.0.0
public static final String DISABLED_ACTION_MODE_MENU_ITEMS

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

Constant Value: "DISABLED_ACTION_MODE_MENU_ITEMS"

OFF_SCREEN_PRERASTER

added in version 1.0.0
public static final String OFF_SCREEN_PRERASTER

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

Constant Value: "OFF_SCREEN_PRERASTER"

POST_WEB_MESSAGE

added in version 1.0.0
public static final String POST_WEB_MESSAGE

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

Constant Value: "POST_WEB_MESSAGE"

RECEIVE_HTTP_ERROR

added in version 1.0.0
public static final String RECEIVE_HTTP_ERROR

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

Constant Value: "RECEIVE_HTTP_ERROR"

RECEIVE_WEB_RESOURCE_ERROR

added in version 1.0.0
public static final String RECEIVE_WEB_RESOURCE_ERROR

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

Constant Value: "RECEIVE_WEB_RESOURCE_ERROR"

SAFE_BROWSING_ENABLE

added in version 1.0.0
public static final String SAFE_BROWSING_ENABLE

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

Constant Value: "SAFE_BROWSING_ENABLE"

SAFE_BROWSING_HIT

added in version 1.0.0
public static final String SAFE_BROWSING_HIT

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

Constant Value: "SAFE_BROWSING_HIT"

SAFE_BROWSING_PRIVACY_POLICY_URL

added in version 1.0.0
public static final String SAFE_BROWSING_PRIVACY_POLICY_URL

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

Constant Value: "SAFE_BROWSING_PRIVACY_POLICY_URL"

SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY

added in version 1.0.0
public static final String SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY

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

Constant Value: "SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"

SAFE_BROWSING_RESPONSE_PROCEED

added in version 1.0.0
public static final String SAFE_BROWSING_RESPONSE_PROCEED

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

Constant Value: "SAFE_BROWSING_RESPONSE_PROCEED"

SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL

added in version 1.0.0
public static final String SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL

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

Constant Value: "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"

SAFE_BROWSING_WHITELIST

added in version 1.0.0
public static final String SAFE_BROWSING_WHITELIST

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

Constant Value: "SAFE_BROWSING_WHITELIST"

SERVICE_WORKER_BASIC_USAGE

added in version 1.0.0
public static final String SERVICE_WORKER_BASIC_USAGE

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

Constant Value: "SERVICE_WORKER_BASIC_USAGE"

SERVICE_WORKER_BLOCK_NETWORK_LOADS

added in version 1.0.0
public static final String SERVICE_WORKER_BLOCK_NETWORK_LOADS

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

Constant Value: "SERVICE_WORKER_BLOCK_NETWORK_LOADS"

SERVICE_WORKER_CACHE_MODE

added in version 1.0.0
public static final String SERVICE_WORKER_CACHE_MODE

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

Constant Value: "SERVICE_WORKER_CACHE_MODE"

SERVICE_WORKER_CONTENT_ACCESS

added in version 1.0.0
public static final String SERVICE_WORKER_CONTENT_ACCESS

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

Constant Value: "SERVICE_WORKER_CONTENT_ACCESS"

SERVICE_WORKER_FILE_ACCESS

added in version 1.0.0
public static final String SERVICE_WORKER_FILE_ACCESS

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

Constant Value: "SERVICE_WORKER_FILE_ACCESS"

SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

added in version 1.0.0
public static final String SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST

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

Constant Value: "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"

SHOULD_OVERRIDE_WITH_REDIRECTS

added in version 1.0.0
public static final String SHOULD_OVERRIDE_WITH_REDIRECTS

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

Constant Value: "SHOULD_OVERRIDE_WITH_REDIRECTS"

START_SAFE_BROWSING

added in version 1.0.0
public static final String START_SAFE_BROWSING

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

Constant Value: "START_SAFE_BROWSING"

VISUAL_STATE_CALLBACK

added in version 1.0.0
public static final String VISUAL_STATE_CALLBACK

Feature for isFeatureSupported(String). This feature covers WebViewCompat.postVisualStateCallback(android.webkit.WebView, long, WebViewCompat.VisualStateCallback), and WebViewClientCompat.onPageCommitVisible(android.webkit.WebView, String).

Constant Value: "VISUAL_STATE_CALLBACK"

WEB_MESSAGE_CALLBACK_ON_MESSAGE

added in version 1.0.0
public static final String WEB_MESSAGE_CALLBACK_ON_MESSAGE

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

Constant Value: "WEB_MESSAGE_CALLBACK_ON_MESSAGE"

WEB_MESSAGE_PORT_CLOSE

added in version 1.0.0
public static final String WEB_MESSAGE_PORT_CLOSE

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

Constant Value: "WEB_MESSAGE_PORT_CLOSE"

WEB_MESSAGE_PORT_POST_MESSAGE

added in version 1.0.0
public static final String WEB_MESSAGE_PORT_POST_MESSAGE

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

Constant Value: "WEB_MESSAGE_PORT_POST_MESSAGE"

WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK

added in version 1.0.0
public static final String WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK

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

Constant Value: "WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"

WEB_RESOURCE_ERROR_GET_CODE

added in version 1.0.0
public static final String WEB_RESOURCE_ERROR_GET_CODE

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

Constant Value: "WEB_RESOURCE_ERROR_GET_CODE"

WEB_RESOURCE_ERROR_GET_DESCRIPTION

added in version 1.0.0
public static final String WEB_RESOURCE_ERROR_GET_DESCRIPTION

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

Constant Value: "WEB_RESOURCE_ERROR_GET_DESCRIPTION"

WEB_RESOURCE_REQUEST_IS_REDIRECT

added in version 1.0.0
public static final String WEB_RESOURCE_REQUEST_IS_REDIRECT

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

Constant Value: "WEB_RESOURCE_REQUEST_IS_REDIRECT"

Public methods

isFeatureSupported

added in version 1.0.0
public static boolean isFeatureSupported (String feature)

Return whether a feature is supported at run-time. On devices running Android version Build.VERSION_CODES.LOLLIPOP 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

Returns
boolean whether the feature is supported given the current platform SDK and webview version