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

ServiceWorkerWebSettingsCompat

public abstract class ServiceWorkerWebSettingsCompat
extends Object

java.lang.Object
   ↳ androidx.webkit.ServiceWorkerWebSettingsCompat


Manages settings state for all Service Workers. These settings are not tied to the lifetime of any WebView because service workers can outlive WebView instances. The settings are similar to WebSettings but only settings relevant to Service Workers are supported.

Summary

Public methods

abstract boolean getAllowContentAccess()

Gets whether Service Workers support content URL access.

abstract boolean getAllowFileAccess()

Gets whether Service Workers support file access.

abstract boolean getBlockNetworkLoads()

Gets whether Service Workers are prohibited from loading any resources from the network.

abstract int getCacheMode()

Gets the current setting for overriding the cache mode.

abstract void setAllowContentAccess(boolean allow)

Enables or disables content URL access from Service Workers, see WebSettings.setAllowContentAccess(boolean).

abstract void setAllowFileAccess(boolean allow)

Enables or disables file access within Service Workers, see WebSettings.setAllowFileAccess(boolean).

abstract void setBlockNetworkLoads(boolean flag)

Sets whether Service Workers should not load resources from the network, see WebSettings.setBlockNetworkLoads(boolean).

abstract void setCacheMode(int mode)

Overrides the way the cache is used, see WebSettings.setCacheMode(int).

Inherited methods

Public methods

getAllowContentAccess

added in version 1.0.0
public abstract boolean getAllowContentAccess ()

Gets whether Service Workers support content URL access.

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS.

Returns
boolean

getAllowFileAccess

added in version 1.0.0
public abstract boolean getAllowFileAccess ()

Gets whether Service Workers support file access.

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_FILE_ACCESS.

Returns
boolean

getBlockNetworkLoads

added in version 1.0.0
public abstract boolean getBlockNetworkLoads ()

Gets whether Service Workers are prohibited from loading any resources from the network.

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS.

Returns
boolean true if the Service Workers are not allowed to load any resources from the network

getCacheMode

added in version 1.0.0
public abstract int getCacheMode ()

Gets the current setting for overriding the cache mode.

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_CACHE_MODE.

Returns
int the current setting for overriding the cache mode

See also:

setAllowContentAccess

added in version 1.0.0
public abstract void setAllowContentAccess (boolean allow)

Enables or disables content URL access from Service Workers, see WebSettings.setAllowContentAccess(boolean).

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS.

Parameters
allow boolean

setAllowFileAccess

added in version 1.0.0
public abstract void setAllowFileAccess (boolean allow)

Enables or disables file access within Service Workers, see WebSettings.setAllowFileAccess(boolean).

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_FILE_ACCESS.

Parameters
allow boolean

setBlockNetworkLoads

added in version 1.0.0
public abstract void setBlockNetworkLoads (boolean flag)

Sets whether Service Workers should not load resources from the network, see WebSettings.setBlockNetworkLoads(boolean).

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS.

Parameters
flag boolean: true means block network loads by the Service Workers

setCacheMode

added in version 1.0.0
public abstract void setCacheMode (int mode)

Overrides the way the cache is used, see WebSettings.setCacheMode(int).

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.SERVICE_WORKER_CACHE_MODE.

Parameters
mode int: the mode to use. One of WebSettings.LOAD_DEFAULT, WebSettings.LOAD_CACHE_ELSE_NETWORK, WebSettings.LOAD_NO_CACHE or WebSettings.LOAD_CACHE_ONLY. The default value is WebSettings.LOAD_DEFAULT.