public abstract class ServiceWorkerControllerCompat
extends Object

   ↳ androidx.webkit.ServiceWorkerControllerCompat

Manages Service Workers used by WebView.

Example usage:

 ServiceWorkerControllerCompat swController = ServiceWorkerControllerCompat.getInstance();
 swController.setServiceWorkerClient(new ServiceWorkerClientCompat() {
   public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
     // Capture request here and generate response or allow pass-through
     // by returning null.
     return null;


Public methods

static ServiceWorkerControllerCompat getInstance()

Returns the default ServiceWorkerController instance.

abstract ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings()

Gets the settings for all service workers.

abstract void setServiceWorkerClient(ServiceWorkerClientCompat client)

Sets the client to capture service worker related callbacks.

Inherited methods

Public methods


public static ServiceWorkerControllerCompat getInstance ()

Returns the default ServiceWorkerController instance. At present there is only one ServiceWorkerController instance for all WebView instances, however this restriction may be relaxed in the future.

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

ServiceWorkerControllerCompat the default ServiceWorkerController instance


public abstract ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings ()

Gets the settings for all service workers.