Most visited

Recently visited

Added in API level 24

ServiceWorkerController

public abstract class ServiceWorkerController
extends Object

java.lang.Object
   ↳ android.webkit.ServiceWorkerController


管理WebView使用的服务人员。

用法示例:

 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;
   }
 });
 

Summary

Public constructors

ServiceWorkerController()

Public methods

static ServiceWorkerController getInstance()

返回默认的ServiceWorkerController实例。

abstract ServiceWorkerWebSettings getServiceWorkerWebSettings()

获取所有服务人员的设置。

abstract void setServiceWorkerClient(ServiceWorkerClient client)

设置客户端以捕获与服务人员相关的回调。

Inherited methods

From class java.lang.Object

Public constructors

ServiceWorkerController

Added in API level 24
ServiceWorkerController ()

Public methods

getInstance

Added in API level 24
ServiceWorkerController getInstance ()

返回默认的ServiceWorkerController实例。 目前,所有WebView实例都只有一个ServiceWorkerController实例,但是这个限制将来可能会放松。

Returns
ServiceWorkerController the default ServiceWorkerController instance

getServiceWorkerWebSettings

Added in API level 24
ServiceWorkerWebSettings getServiceWorkerWebSettings ()

获取所有服务人员的设置。

Returns
ServiceWorkerWebSettings the current ServiceWorkerWebSettings

setServiceWorkerClient

Added in API level 24
void setServiceWorkerClient (ServiceWorkerClient client)

设置客户端以捕获与服务人员相关的回调。 在任何服务人员处于活动状态之前应该设置ServiceWorkerClient ,例如,在创建任何WebView实例或加载页面之前,安全的地方是。

Parameters
client ServiceWorkerClient

Hooray!