Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/webkit/ServiceWorkerController#pubctors) \| [Methods](https://developer.android.com/reference/android/webkit/ServiceWorkerController#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/webkit/ServiceWorkerController#inhmethods)

# ServiceWorkerController

*** ** * ** ***

` public abstract class ServiceWorkerController `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.webkit.ServiceWorkerController |

<br />

*** ** * ** ***

Manages Service Workers used by WebView.

Example usage:

```
ServiceWorkerController swController = ServiceWorkerController.getInstance();
swController.setServiceWorkerClient(new ServiceWorkerClient() {
  @Override
  public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
    // Capture request here and generate response or allow pass-through
    // by returning null.
    return null;
  }
});
```

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/webkit/ServiceWorkerController#ServiceWorkerController()() ` *This constructor is deprecated. This class should not be constructed by applications, use `https://developer.android.com/reference/android/webkit/ServiceWorkerController#getInstance()` instead to fetch the singleton instance.* |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/webkit/ServiceWorkerController` | ` https://developer.android.com/reference/android/webkit/ServiceWorkerController#getInstance()() ` Returns the default ServiceWorkerController instance. |
| ` abstract https://developer.android.com/reference/android/webkit/ServiceWorkerWebSettings` | ` https://developer.android.com/reference/android/webkit/ServiceWorkerController#getServiceWorkerWebSettings()() ` Gets the settings for all service workers. |
| ` abstract void` | ` https://developer.android.com/reference/android/webkit/ServiceWorkerController#setServiceWorkerClient(android.webkit.ServiceWorkerClient)(https://developer.android.com/reference/android/webkit/ServiceWorkerClient client) ` Sets the client to capture service worker related callbacks. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### ServiceWorkerController

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ServiceWorkerController ()
```

<br />

**This constructor is deprecated.**   

This class should not be constructed by applications, use `https://developer.android.com/reference/android/webkit/ServiceWorkerController#getInstance()` instead to fetch the singleton instance.

<br />

<br />

## Public methods

### getInstance

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static ServiceWorkerController 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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/webkit/ServiceWorkerController` | the default ServiceWorkerController instance. This value cannot be `null`. <br /> |

### getServiceWorkerWebSettings

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract ServiceWorkerWebSettings getServiceWorkerWebSettings ()
```

Gets the settings for all service workers.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/webkit/ServiceWorkerWebSettings` | the current ServiceWorkerWebSettings. This value cannot be `null`. <br /> |

### setServiceWorkerClient

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setServiceWorkerClient (ServiceWorkerClient client)
```

Sets the client to capture service worker related callbacks. A `https://developer.android.com/reference/android/webkit/ServiceWorkerClient` should be set before any service workers are active, e.g. a safe place is before any WebView instances are created or pages loaded.

<br />

| Parameters ||
|---|---|
| `client` | `ServiceWorkerClient`: This value may be `null`. <br /> |