# WebViewClient

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

# WebViewClient

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/webkit/WebViewClient "View this page in Kotlin")\|Java

`
public


class
WebViewClient
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

## Summary

|                                                                                                        ### Constants                                                                                                         ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [ERROR_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION) User authentication failed on server                                                                |
| `int` | [ERROR_BAD_URL](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_BAD_URL) Malformed URL                                                                                                     |
| `int` | [ERROR_CONNECT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT) Failed to connect to the server                                                                                   |
| `int` | [ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE) Failed to perform SSL handshake                                                         |
| `int` | [ERROR_FILE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE) Generic file error                                                                                                      |
| `int` | [ERROR_FILE_NOT_FOUND](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE_NOT_FOUND) File not found                                                                                      |
| `int` | [ERROR_HOST_LOOKUP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP) Server or proxy hostname lookup failed                                                                    |
| `int` | [ERROR_IO](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_IO) Failed to read or write to the server                                                                                       |
| `int` | [ERROR_PROXY_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_PROXY_AUTHENTICATION) User authentication failed on proxy                                                     |
| `int` | [ERROR_REDIRECT_LOOP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_REDIRECT_LOOP) Too many redirects                                                                                    |
| `int` | [ERROR_TIMEOUT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT) Connection timed out                                                                                              |
| `int` | [ERROR_TOO_MANY_REQUESTS](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TOO_MANY_REQUESTS) Too many requests during this load                                                            |
| `int` | [ERROR_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN) Generic error                                                                                                     |
| `int` | [ERROR_UNSAFE_RESOURCE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSAFE_RESOURCE) Resource load was canceled by Safe Browsing                                                       |
| `int` | [ERROR_UNSUPPORTED_AUTH_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_AUTH_SCHEME) Unsupported authentication scheme (not basic or digest)                           |
| `int` | [ERROR_UNSUPPORTED_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_SCHEME) Unsupported URI scheme                                                                      |
| `int` | [SAFE_BROWSING_THREAT_BILLING](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_BILLING) The resource was blocked because it may trick the user into a billing agreement.    |
| `int` | [SAFE_BROWSING_THREAT_MALWARE](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_MALWARE) The resource was blocked because it contains malware.                               |
| `int` | [SAFE_BROWSING_THREAT_PHISHING](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_PHISHING) The resource was blocked because it contains deceptive content.                   |
| `int` | [SAFE_BROWSING_THREAT_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_UNKNOWN) The resource was blocked for an unknown reason.                                     |
| `int` | [SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE) The resource was blocked because it contains unwanted software. |

|                                             ### Public constructors                                              ||
|---------------------------------------------------------------------------------------------------------------|---|
| ` `[WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient#WebViewClient())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                              | ` `[doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url, boolean isReload) ` Notify the host application to update its visited links database.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                              | ` `[onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[Message](https://developer.android.com/reference/android/os/Message)` dontResend, `[Message](https://developer.android.com/reference/android/os/Message)` resend) ` As the host application if the browser should resend data as the requested page was a result of a POST.                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                              | ` `[onLoadResource](https://developer.android.com/reference/android/webkit/WebViewClient#onLoadResource(android.webkit.WebView,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url) ` Notify the host application that the WebView will load the resource specified by the given url.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` void`                                                                                              | ` `[onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url) ` Notify the host application that[WebView](https://developer.android.com/reference/android/webkit/WebView)content left over from previous page navigations will no longer be drawn.                                                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                                              | ` `[onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url) ` Notify the host application that a page has finished loading.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                              | ` `[onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` favicon) ` Notify the host application that a page has started loading.                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                              | ` `[onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[ClientCertRequest](https://developer.android.com/reference/android/webkit/ClientCertRequest)` request) ` Notify the host application to handle a SSL client certificate request.                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                              | ` `[onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20int,%20java.lang.String,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, int errorCode, `[String](https://developer.android.com/reference/java/lang/String)` description, `[String](https://developer.android.com/reference/java/lang/String)` failingUrl) ` *This method was deprecated in API level 23. Use[onReceivedError(WebView, WebResourceRequest, WebResourceError)](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))on[Build.VERSION_CODES.M](https://developer.android.com/reference/android/os/Build.VERSION_CODES#M)and above.* |
| ` void`                                                                                              | ` `[onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[WebResourceRequest](https://developer.android.com/reference/android/webkit/WebResourceRequest)` request, `[WebResourceError](https://developer.android.com/reference/android/webkit/WebResourceError)` error) ` Report web resource loading error to the host application.                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                              | ` `[onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[HttpAuthHandler](https://developer.android.com/reference/android/webkit/HttpAuthHandler)` handler, `[String](https://developer.android.com/reference/java/lang/String)` host, `[String](https://developer.android.com/reference/java/lang/String)` realm) ` Notifies the host application that the WebView received an HTTP authentication request.                                                                                                                                                                                                     |
| ` void`                                                                                              | ` `[onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[WebResourceRequest](https://developer.android.com/reference/android/webkit/WebResourceRequest)` request, `[WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse)` errorResponse) ` Notify the host application that an HTTP error has been received from the server while loading a resource.                                                                                                                                                                                                                           |
| ` void`                                                                                              | ` `[onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` realm, `[String](https://developer.android.com/reference/java/lang/String)` account, `[String](https://developer.android.com/reference/java/lang/String)` args) ` Notify the host application that a request to automatically log in the user has been processed.                                                                                                                                                                                                                                        |
| ` void`                                                                                              | ` `[onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[SslErrorHandler](https://developer.android.com/reference/android/webkit/SslErrorHandler)` handler, `[SslError](https://developer.android.com/reference/android/net/http/SslError)` error) ` Notifies the host application that an SSL error occurred while loading a resource.                                                                                                                                                                                                                                                                                                   |
| ` boolean`                                                                                           | ` `[onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[RenderProcessGoneDetail](https://developer.android.com/reference/android/webkit/RenderProcessGoneDetail)` detail) ` Notify host application that the given WebView's render process has exited.                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                                              | ` `[onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[WebResourceRequest](https://developer.android.com/reference/android/webkit/WebResourceRequest)` request, int threatType, `[SafeBrowsingResponse](https://developer.android.com/reference/android/webkit/SafeBrowsingResponse)` callback) ` Notify the host application that a loading URL has been flagged by Safe Browsing.                                                                                                                                                                                                                                   |
| ` void`                                                                                              | ` `[onScaleChanged](https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, float oldScale, float newScale) ` Notify the host application that the scale applied to the WebView has changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                              | ` `[onTooManyRedirects](https://developer.android.com/reference/android/webkit/WebViewClient#onTooManyRedirects(android.webkit.WebView,%20android.os.Message,%20android.os.Message))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[Message](https://developer.android.com/reference/android/os/Message)` cancelMsg, `[Message](https://developer.android.com/reference/android/os/Message)` continueMsg) ` *This method was deprecated in API level 15. This method is no longer called. When the WebView encounters a redirect loop, it will cancel the load.*                                                                                                                                                                                                                                                                        |
| ` void`                                                                                              | ` `[onUnhandledKeyEvent](https://developer.android.com/reference/android/webkit/WebViewClient#onUnhandledKeyEvent(android.webkit.WebView,%20android.view.KeyEvent))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Notify the host application that a key was not handled by the WebView.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` `[WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse) | ` `[shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[WebResourceRequest](https://developer.android.com/reference/android/webkit/WebResourceRequest)` request) ` Notify the host application of a resource request and allow the application to return the data.                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse) | ` `[shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url) ` *This method was deprecated in API level 21. Use[shouldInterceptRequest(WebView, WebResourceRequest)](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))on[Build.VERSION_CODES.M](https://developer.android.com/reference/android/os/Build.VERSION_CODES#M)and above.*                                                                                                                                                             |
| ` boolean`                                                                                           | ` `[shouldOverrideKeyEvent](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideKeyEvent(android.webkit.WebView,%20android.view.KeyEvent))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Give the host application a chance to handle the key event synchronously.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` boolean`                                                                                           | ` `[shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[WebResourceRequest](https://developer.android.com/reference/android/webkit/WebResourceRequest)` request) ` Give the host application a chance to take control when a URL is about to be loaded in the current WebView.                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                           | ` `[shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` view, `[String](https://developer.android.com/reference/java/lang/String)` url) ` *This method was deprecated in API level 24. Use[shouldOverrideUrlLoading(WebView, WebResourceRequest)](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest))on[Build.VERSION_CODES.N](https://developer.android.com/reference/android/os/Build.VERSION_CODES#N)and above.*                                                                                                                                                     |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Constants

### ERROR_AUTHENTICATION

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

```
public static final int ERROR_AUTHENTICATION
```

User authentication failed on server

<br />

Constant Value: -4 (0xfffffffc)  

### ERROR_BAD_URL

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

```
public static final int ERROR_BAD_URL
```

Malformed URL

<br />

Constant Value: -12 (0xfffffff4)  

### ERROR_CONNECT

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

```
public static final int ERROR_CONNECT
```

Failed to connect to the server

<br />

Constant Value: -6 (0xfffffffa)  

### ERROR_FAILED_SSL_HANDSHAKE

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

```
public static final int ERROR_FAILED_SSL_HANDSHAKE
```

Failed to perform SSL handshake

<br />

Constant Value: -11 (0xfffffff5)  

### ERROR_FILE

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

```
public static final int ERROR_FILE
```

Generic file error

<br />

Constant Value: -13 (0xfffffff3)  

### ERROR_FILE_NOT_FOUND

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

```
public static final int ERROR_FILE_NOT_FOUND
```

File not found

<br />

Constant Value: -14 (0xfffffff2)  

### ERROR_HOST_LOOKUP

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

```
public static final int ERROR_HOST_LOOKUP
```

Server or proxy hostname lookup failed

<br />

Constant Value: -2 (0xfffffffe)  

### ERROR_IO

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

```
public static final int ERROR_IO
```

Failed to read or write to the server

<br />

Constant Value: -7 (0xfffffff9)  

### ERROR_PROXY_AUTHENTICATION

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

```
public static final int ERROR_PROXY_AUTHENTICATION
```

User authentication failed on proxy

<br />

Constant Value: -5 (0xfffffffb)  

### ERROR_REDIRECT_LOOP

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

```
public static final int ERROR_REDIRECT_LOOP
```

Too many redirects

<br />

Constant Value: -9 (0xfffffff7)  

### ERROR_TIMEOUT

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

```
public static final int ERROR_TIMEOUT
```

Connection timed out

<br />

Constant Value: -8 (0xfffffff8)  

### ERROR_TOO_MANY_REQUESTS

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

```
public static final int ERROR_TOO_MANY_REQUESTS
```

Too many requests during this load

<br />

Constant Value: -15 (0xfffffff1)  

### ERROR_UNKNOWN

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

```
public static final int ERROR_UNKNOWN
```

Generic error

<br />

Constant Value: -1 (0xffffffff)  

### ERROR_UNSAFE_RESOURCE

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

```
public static final int ERROR_UNSAFE_RESOURCE
```

Resource load was canceled by Safe Browsing

<br />

Constant Value: -16 (0xfffffff0)  

### ERROR_UNSUPPORTED_AUTH_SCHEME

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

```
public static final int ERROR_UNSUPPORTED_AUTH_SCHEME
```

Unsupported authentication scheme (not basic or digest)

<br />

Constant Value: -3 (0xfffffffd)  

### ERROR_UNSUPPORTED_SCHEME

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

```
public static final int ERROR_UNSUPPORTED_SCHEME
```

Unsupported URI scheme

<br />

Constant Value: -10 (0xfffffff6)  

### SAFE_BROWSING_THREAT_BILLING

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

```
public static final int SAFE_BROWSING_THREAT_BILLING
```

The resource was blocked because it may trick the user into a billing agreement.

This constant is only used when targetSdkVersion is at least[Build.VERSION_CODES.Q](https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q). Otherwise,[SAFE_BROWSING_THREAT_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_UNKNOWN)is used instead.

<br />

Constant Value: 4 (0x00000004)  

### SAFE_BROWSING_THREAT_MALWARE

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

```
public static final int SAFE_BROWSING_THREAT_MALWARE
```

The resource was blocked because it contains malware.

<br />

Constant Value: 1 (0x00000001)  

### SAFE_BROWSING_THREAT_PHISHING

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

```
public static final int SAFE_BROWSING_THREAT_PHISHING
```

The resource was blocked because it contains deceptive content.

<br />

Constant Value: 2 (0x00000002)  

### SAFE_BROWSING_THREAT_UNKNOWN

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

```
public static final int SAFE_BROWSING_THREAT_UNKNOWN
```

The resource was blocked for an unknown reason.

<br />

Constant Value: 0 (0x00000000)  

### SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE

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

```
public static final int SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE
```

The resource was blocked because it contains unwanted software.

<br />

Constant Value: 3 (0x00000003)

## Public constructors

### WebViewClient

```
public WebViewClient ()
```

<br />

<br />

## Public methods

### doUpdateVisitedHistory

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

```
public void doUpdateVisitedHistory (WebView view, 
                String url, 
                boolean isReload)
```

Notify the host application to update its visited links database.

<br />

|                                 Parameters                                 ||
|------------|----------------------------------------------------------------|
| `view`     | `WebView`: The WebView that is initiating the callback. <br /> |
| `url`      | `String`: The url being visited. <br />                        |
| `isReload` | `boolean`:`true`if this url is being reloaded. <br />          |

### onFormResubmission

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

```
public void onFormResubmission (WebView view, 
                Message dontResend, 
                Message resend)
```

As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data.

<br />

|                                      Parameters                                       ||
|--------------|-------------------------------------------------------------------------|
| `view`       | `WebView`: The WebView that is initiating the callback. <br />          |
| `dontResend` | `Message`: The message to send if the browser should not resend <br />  |
| `resend`     | `Message`: The message to send if the browser should resend data <br /> |

### onLoadResource

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

```
public void onLoadResource (WebView view, 
                String url)
```

Notify the host application that the WebView will load the resource specified by the given url.

<br />

|                               Parameters                                ||
|--------|-----------------------------------------------------------------|
| `view` | `WebView`: The WebView that is initiating the callback. <br />  |
| `url`  | `String`: The url of the resource the WebView will load. <br /> |

### onPageCommitVisible

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

```
public void onPageCommitVisible (WebView view, 
                String url)
```

Notify the host application that[WebView](https://developer.android.com/reference/android/webkit/WebView)content left over from previous page navigations will no longer be drawn.

This callback can be used to determine the point at which it is safe to make a recycled[WebView](https://developer.android.com/reference/android/webkit/WebView)visible, ensuring that no stale content is shown. It is called at the earliest point at which it can be guaranteed that[WebView.onDraw](https://developer.android.com/reference/android/webkit/WebView#onDraw(android.graphics.Canvas))will no longer draw any content from previous navigations. The next draw will display either the[background color](https://developer.android.com/reference/android/webkit/WebView#setBackgroundColor(int))of the[WebView](https://developer.android.com/reference/android/webkit/WebView), or some of the contents of the newly loaded page.

This method is called when the body of the HTTP response has started loading, is reflected in the DOM, and will be visible in subsequent draws. This callback occurs early in the document loading process, and as such you should expect that linked resources (for example, CSS and images) may not be available.

For more fine-grained notification of visual state updates, see[WebView.postVisualStateCallback(long, VisualStateCallback)](https://developer.android.com/reference/android/webkit/WebView#postVisualStateCallback(long,%20android.webkit.WebView.VisualStateCallback)).

Please note that all the conditions and recommendations applicable to[WebView.postVisualStateCallback](https://developer.android.com/reference/android/webkit/WebView#postVisualStateCallback(long,%20android.webkit.WebView.VisualStateCallback))also apply to this API.

This callback is only called for main frame navigations.

<br />

|                                                                Parameters                                                                ||
|--------|----------------------------------------------------------------------------------------------------------------------------------|
| `view` | `WebView`: The[WebView](https://developer.android.com/reference/android/webkit/WebView)for which the navigation occurred. <br /> |
| `url`  | `String`: The URL corresponding to the page navigation that triggered this callback. <br />                                      |

### onPageFinished

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

```
public void onPageFinished (WebView view, 
                String url)
```

Notify the host application that a page has finished loading. This method is called only for main frame. Receiving an`onPageFinished()`callback does not guarantee that the next frame drawn by WebView will reflect the state of the DOM at this point. In order to be notified that the current DOM state is ready to be rendered, request a visual state callback with[WebView.postVisualStateCallback](https://developer.android.com/reference/android/webkit/WebView#postVisualStateCallback(long,%20android.webkit.WebView.VisualStateCallback))and wait for the supplied callback to be triggered.

<br />

|                               Parameters                               ||
|--------|----------------------------------------------------------------|
| `view` | `WebView`: The WebView that is initiating the callback. <br /> |
| `url`  | `String`: The url of the page. <br />                          |

### onPageStarted

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

```
public void onPageStarted (WebView view, 
                String url, 
                Bitmap favicon)
```

Notify the host application that a page has started loading. This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted one time for the main frame. This also means that onPageStarted will not be called when the contents of an embedded frame changes, i.e. clicking a link whose target is an iframe, it will also not be called for fragment navigations (navigations to #fragment_id).

<br />

|                                         Parameters                                          ||
|-----------|----------------------------------------------------------------------------------|
| `view`    | `WebView`: The WebView that is initiating the callback. <br />                   |
| `url`     | `String`: The url to be loaded. <br />                                           |
| `favicon` | `Bitmap`: The favicon for this page if it already exists in the database. <br /> |

### onReceivedClientCertRequest

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

```
public void onReceivedClientCertRequest (WebView view, 
                ClientCertRequest request)
```

Notify the host application to handle a SSL client certificate request. The host application is responsible for showing the UI if desired and providing the keys. There are three ways to respond:[ClientCertRequest.proceed](https://developer.android.com/reference/android/webkit/ClientCertRequest#proceed(java.security.PrivateKey,%20java.security.cert.X509Certificate[])),[ClientCertRequest.cancel](https://developer.android.com/reference/android/webkit/ClientCertRequest#cancel()), or[ClientCertRequest.ignore()](https://developer.android.com/reference/android/webkit/ClientCertRequest#ignore()). Webview stores the response in memory (for the life of the application) if[ClientCertRequest.proceed](https://developer.android.com/reference/android/webkit/ClientCertRequest#proceed(java.security.PrivateKey,%20java.security.cert.X509Certificate[]))or[ClientCertRequest.cancel](https://developer.android.com/reference/android/webkit/ClientCertRequest#cancel())is called and does not call`onReceivedClientCertRequest()`again for the same host and port pair. Webview does not store the response if[ClientCertRequest.ignore](https://developer.android.com/reference/android/webkit/ClientCertRequest#ignore())is called. Note that, multiple layers in chromium network stack might be caching the responses, so the behavior for ignore is only a best case effort. This method is called on the UI thread. During the callback, the connection is suspended. For most use cases, the application program should implement the[KeyChainAliasCallback](https://developer.android.com/reference/android/security/KeyChainAliasCallback)interface and pass it to[KeyChain.choosePrivateKeyAlias(Activity, KeyChainAliasCallback, String, Principal, Uri, String)](https://developer.android.com/reference/android/security/KeyChain#choosePrivateKeyAlias(android.app.Activity,%20android.security.KeyChainAliasCallback,%20java.lang.String[],%20java.security.Principal[],%20android.net.Uri,%20java.lang.String))to start an activity for the user to choose the proper alias. The keychain activity will provide the alias through the callback method in the implemented interface. Next the application should create an async task to call[KeyChain.getPrivateKey(Context, String)](https://developer.android.com/reference/android/security/KeyChain#getPrivateKey(android.content.Context,%20java.lang.String))to receive the key. An example implementation of client certificates can be seen at[AOSP Browser](https://android.googlesource.com/platform/packages/apps/Browser/+/android-5.1.1_r1/src/com/android/browser/Tab.java)The default behavior is to cancel, returning no client certificate.

<br />

|                                                                      Parameters                                                                      ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `view`    | `WebView`: The WebView that is initiating the callback <br />                                                                             |
| `request` | `ClientCertRequest`: An instance of a[ClientCertRequest](https://developer.android.com/reference/android/webkit/ClientCertRequest) <br /> |

### onReceivedError

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

```
public void onReceivedError (WebView view, 
                int errorCode, 
                String description, 
                String failingUrl)
```

<br />

**This method was deprecated in API level 23.**   
Use[onReceivedError(WebView, WebResourceRequest, WebResourceError)](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))on[Build.VERSION_CODES.M](https://developer.android.com/reference/android/os/Build.VERSION_CODES#M)and above.

Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable). The`errorCode`parameter corresponds to one of the`ERROR_*`constants.

<br />

|                                   Parameters                                    ||
|---------------|------------------------------------------------------------------|
| `view`        | `WebView`: The WebView that is initiating the callback. <br />   |
| `errorCode`   | `int`: The error code corresponding to an ERROR_\* value. <br /> |
| `description` | `String`: A String describing the error. <br />                  |
| `failingUrl`  | `String`: The url that failed to load. <br />                    |

### onReceivedError

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

```
public void onReceivedError (WebView view, 
                WebResourceRequest request, 
                WebResourceError error)
```

Report web resource loading error to the host application. These errors usually indicate inability to connect to the server. Note that unlike the deprecated version of the callback, the new version will be called for any resource (iframe, image, etc.), not just for the main page. Thus, it is recommended to perform minimum required work in this callback.

<br />

|                                 Parameters                                  ||
|-----------|------------------------------------------------------------------|
| `view`    | `WebView`: The WebView that is initiating the callback. <br />   |
| `request` | `WebResourceRequest`: The originating request. <br />            |
| `error`   | `WebResourceError`: Information about the error occurred. <br /> |

### onReceivedHttpAuthRequest

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

```
public void onReceivedHttpAuthRequest (WebView view, 
                HttpAuthHandler handler, 
                String host, 
                String realm)
```

Notifies the host application that the WebView received an HTTP authentication request. The host application can use the supplied[HttpAuthHandler](https://developer.android.com/reference/android/webkit/HttpAuthHandler)to set the WebView's response to the request. The default behavior is to cancel the request.

**Note:**The supplied HttpAuthHandler must be used on the UI thread.

<br />

|                                         Parameters                                          ||
|-----------|----------------------------------------------------------------------------------|
| `view`    | `WebView`: the WebView that is initiating the callback <br />                    |
| `handler` | `HttpAuthHandler`: the HttpAuthHandler used to set the WebView's response <br /> |
| `host`    | `String`: the host requiring authentication <br />                               |
| `realm`   | `String`: the realm for which authentication is required <br />                  |

**See also:**

- [WebView.getHttpAuthUsernamePassword(String, String)](https://developer.android.com/reference/android/webkit/WebView#getHttpAuthUsernamePassword(java.lang.String,%20java.lang.String))  

### onReceivedHttpError

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

```
public void onReceivedHttpError (WebView view, 
                WebResourceRequest request, 
                WebResourceResponse errorResponse)
```

Notify the host application that an HTTP error has been received from the server while loading a resource. HTTP errors have status codes \>= 400. This callback will be called for any resource (iframe, image, etc.), not just for the main page. Thus, it is recommended to perform minimum required work in this callback. Note that the content of the server response may not be provided within the`errorResponse`parameter.

<br />

|                                      Parameters                                      ||
|-----------------|---------------------------------------------------------------------|
| `view`          | `WebView`: The WebView that is initiating the callback. <br />      |
| `request`       | `WebResourceRequest`: The originating request. <br />               |
| `errorResponse` | `WebResourceResponse`: Information about the error occurred. <br /> |

### onReceivedLoginRequest

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

```
public void onReceivedLoginRequest (WebView view, 
                String realm, 
                String account, 
                String args)
```

Notify the host application that a request to automatically log in the user has been processed.

<br />

|                                                                                          Parameters                                                                                          ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `view`    | `WebView`: The WebView requesting the login. <br />                                                                                                                               |
| `realm`   | `String`: The account realm used to look up accounts. <br />                                                                                                                      |
| `account` | `String`: An optional account. If not`null`, the account should be checked against accounts on the device. If it is a valid account, it should be used to log in the user. <br /> |
| `args`    | `String`: Authenticator specific arguments used to log in the user. <br />                                                                                                        |

### onReceivedSslError

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

```
public void onReceivedSslError (WebView view, 
                SslErrorHandler handler, 
                SslError error)
```

Notifies the host application that an SSL error occurred while loading a resource. The host application must call either[SslErrorHandler.cancel()](https://developer.android.com/reference/android/webkit/SslErrorHandler#cancel())or[SslErrorHandler.proceed()](https://developer.android.com/reference/android/webkit/SslErrorHandler#proceed()).

**Warning:** Application overrides of this method can be used to display custom error pages or to silently log issues, but the host application should always call`SslErrorHandler#cancel()`and never proceed past errors.

**Note:** Do not prompt the user about SSL errors. Users are unlikely to be able to make an informed security decision, and`WebView`does not provide a UI for showing the details of the error in a meaningful way.

The decision to call`proceed()`or`cancel()`may be retained to facilitate responses to future SSL errors. The default behavior is to cancel the resource loading process.

This API is called only for recoverable SSL certificate errors. For non-recoverable errors (such as when the server fails the client), the`WebView`calls[onReceivedError(WebView,
WebResourceRequest, WebResourceError)](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))with the[ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE)argument.

<br />

|                                                                           Parameters                                                                           ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| `view`    | `WebView`:`WebView`that initiated the callback. <br />                                                                                              |
| `handler` | `SslErrorHandler`:[SslErrorHandler](https://developer.android.com/reference/android/webkit/SslErrorHandler)that handles the user's response. <br /> |
| `error`   | `SslError`: SSL error object. <br />                                                                                                                |

### onRenderProcessGone

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

```
public boolean onRenderProcessGone (WebView view, 
                RenderProcessGoneDetail detail)
```

Notify host application that the given WebView's render process has exited. Multiple WebView instances may be associated with a single render process; onRenderProcessGone will be called for each WebView that was affected. The application's implementation of this callback should only attempt to clean up the specific WebView given as a parameter, and should not assume that other WebView instances are affected. The given WebView can't be used, and should be removed from the view hierarchy, all references to it should be cleaned up, e.g any references in the Activity or other classes saved using[View.findViewById(int)](https://developer.android.com/reference/android/view/View#findViewById(int))and similar calls, etc. To cause an render process crash for test purpose, the application can call`loadUrl("chrome://crash")`on the WebView. Note that multiple WebView instances may be affected if they share a render process, not just the specific WebView which loaded chrome://crash.

<br />

|                              Parameters                               ||
|----------|-------------------------------------------------------------|
| `view`   | `WebView`: The WebView which needs to be cleaned up. <br /> |
| `detail` | `RenderProcessGoneDetail`: the reason why it exited. <br /> |

|                                                                                                       Returns                                                                                                        ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if the host application handled the situation that process has exited, otherwise, application will crash if render process crashed, or be killed if render process was killed by the system. <br /> |

### onSafeBrowsingHit

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

```
public void onSafeBrowsingHit (WebView view, 
                WebResourceRequest request, 
                int threatType, 
                SafeBrowsingResponse callback)
```

Notify the host application that a loading URL has been flagged by Safe Browsing. The application must invoke the callback to indicate the preferred response. The default behavior is to show an interstitial to the user, with the reporting checkbox visible. If the application needs to show its own custom interstitial UI, the callback can be invoked asynchronously with[SafeBrowsingResponse.backToSafety](https://developer.android.com/reference/android/webkit/SafeBrowsingResponse#backToSafety(boolean))or[SafeBrowsingResponse.proceed(boolean)](https://developer.android.com/reference/android/webkit/SafeBrowsingResponse#proceed(boolean)), depending on user response.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `view`       | `WebView`: The WebView that hit the malicious resource. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `request`    | `WebResourceRequest`: Object containing the details of the request. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `threatType` | `int`: The reason the resource was caught by Safe Browsing, corresponding to a`SAFE_BROWSING_THREAT_*`value. Value is[SAFE_BROWSING_THREAT_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_UNKNOWN),[SAFE_BROWSING_THREAT_MALWARE](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_MALWARE),[SAFE_BROWSING_THREAT_PHISHING](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_PHISHING),[SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE), or[SAFE_BROWSING_THREAT_BILLING](https://developer.android.com/reference/android/webkit/WebViewClient#SAFE_BROWSING_THREAT_BILLING) <br /> |
| `callback`   | `SafeBrowsingResponse`: Applications must invoke one of the callback methods. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

### onScaleChanged

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

```
public void onScaleChanged (WebView view, 
                float oldScale, 
                float newScale)
```

Notify the host application that the scale applied to the WebView has changed.

<br />

|                                 Parameters                                 ||
|------------|----------------------------------------------------------------|
| `view`     | `WebView`: The WebView that is initiating the callback. <br /> |
| `oldScale` | `float`: The old scale factor <br />                           |
| `newScale` | `float`: The new scale factor <br />                           |

### onTooManyRedirects

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

```
public void onTooManyRedirects (WebView view, 
                Message cancelMsg, 
                Message continueMsg)
```

<br />

**This method was deprecated in API level 15.**   
This method is no longer called. When the WebView encounters a redirect loop, it will cancel the load.

Notify the host application that there have been an excessive number of HTTP redirects. As the host application if it would like to continue trying to load the resource. The default behavior is to send the cancel message.

<br />

|                                     Parameters                                     ||
|---------------|---------------------------------------------------------------------|
| `view`        | `WebView`: The WebView that is initiating the callback. <br />      |
| `cancelMsg`   | `Message`: The message to send if the host wants to cancel <br />   |
| `continueMsg` | `Message`: The message to send if the host wants to continue <br /> |

### onUnhandledKeyEvent

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

```
public void onUnhandledKeyEvent (WebView view, 
                KeyEvent event)
```

Notify the host application that a key was not handled by the WebView. Except system keys, WebView always consumes the keys in the normal flow or if[shouldOverrideKeyEvent(WebView, KeyEvent)](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideKeyEvent(android.webkit.WebView,%20android.view.KeyEvent))returns`true`. This is called asynchronously from where the key is dispatched. It gives the host application a chance to handle the unhandled key events.

<br />

|                               Parameters                                ||
|---------|----------------------------------------------------------------|
| `view`  | `WebView`: The WebView that is initiating the callback. <br /> |
| `event` | `KeyEvent`: The key event. <br />                              |

### shouldInterceptRequest

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

```
public WebResourceResponse shouldInterceptRequest (WebView view, 
                WebResourceRequest request)
```

Notify the host application of a resource request and allow the application to return the data. If the return value is`null`, the WebView will continue to load the resource as usual. Otherwise, the return response and data will be used.

This callback is invoked for a variety of URL schemes (e.g.,`http(s):`,`data:`,`file:`, etc.), not only those schemes which send requests over the network. This is not called for`javascript:`URLs,`blob:`URLs, or for assets accessed via`file:///android_asset/`or`file:///android_res/`URLs.

In the case of redirects, this is only called for the initial resource URL, not any subsequent redirect URLs.

**Note:**This method is called on a thread other than the UI thread so clients should exercise caution when accessing private data or the view system.

**Note:** When Safe Browsing is enabled, these URLs still undergo Safe Browsing checks. If this is undesired, you can use[WebView.setSafeBrowsingWhitelist](https://developer.android.com/reference/android/webkit/WebView#setSafeBrowsingWhitelist(java.util.List<java.lang.String>,%20android.webkit.ValueCallback<java.lang.Boolean>))to skip Safe Browsing checks for that host or dismiss the warning in[onSafeBrowsingHit(WebView, WebResourceRequest, int, SafeBrowsingResponse)](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))by calling[SafeBrowsingResponse.proceed](https://developer.android.com/reference/android/webkit/SafeBrowsingResponse#proceed(boolean)).

<br />

|                                                                Parameters                                                                 ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `view`    | `WebView`: The[WebView](https://developer.android.com/reference/android/webkit/WebView)that is requesting the resource. <br /> |
| `request` | `WebResourceRequest`: Object containing the details of the request. <br />                                                     |

|                                                                                                                                                 Returns                                                                                                                                                 ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse) | A[WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse)containing the response information or`null`if the WebView should load the resource itself. <br /> |

### shouldInterceptRequest

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

```
public WebResourceResponse shouldInterceptRequest (WebView view, 
                String url)
```

<br />

**This method was deprecated in API level 21.**   
Use[shouldInterceptRequest(WebView, WebResourceRequest)](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))on[Build.VERSION_CODES.M](https://developer.android.com/reference/android/os/Build.VERSION_CODES#M)and above.

Notify the host application of a resource request and allow the application to return the data. If the return value is`null`, the WebView will continue to load the resource as usual. Otherwise, the return response and data will be used.

This callback is invoked for a variety of URL schemes (e.g.,`http(s):`,`data:`,`file:`, etc.), not only those schemes which send requests over the network. This is not called for`javascript:`URLs,`blob:`URLs, or for assets accessed via`file:///android_asset/`or`file:///android_res/`URLs.

In the case of redirects, this is only called for the initial resource URL, not any subsequent redirect URLs.

**Note:**This method is called on a thread other than the UI thread so clients should exercise caution when accessing private data or the view system.

**Note:** When Safe Browsing is enabled, these URLs still undergo Safe Browsing checks. If this is undesired, you can use[WebView.setSafeBrowsingWhitelist](https://developer.android.com/reference/android/webkit/WebView#setSafeBrowsingWhitelist(java.util.List<java.lang.String>,%20android.webkit.ValueCallback<java.lang.Boolean>))to skip Safe Browsing checks for that host or dismiss the warning in[onSafeBrowsingHit(WebView, WebResourceRequest, int, SafeBrowsingResponse)](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))by calling[SafeBrowsingResponse.proceed](https://developer.android.com/reference/android/webkit/SafeBrowsingResponse#proceed(boolean)).

<br />

|                                                               Parameters                                                               ||
|--------|--------------------------------------------------------------------------------------------------------------------------------|
| `view` | `WebView`: The[WebView](https://developer.android.com/reference/android/webkit/WebView)that is requesting the resource. <br /> |
| `url`  | `String`: The raw url of the resource. <br />                                                                                  |

|                                                                                                                                                 Returns                                                                                                                                                 ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse) | A[WebResourceResponse](https://developer.android.com/reference/android/webkit/WebResourceResponse)containing the response information or`null`if the WebView should load the resource itself. <br /> |

### shouldOverrideKeyEvent

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

```
public boolean shouldOverrideKeyEvent (WebView view, 
                KeyEvent event)
```

Give the host application a chance to handle the key event synchronously. e.g. menu shortcut key events need to be filtered this way. If return true, WebView will not handle the key event. If return`false`, WebView will always handle the key event, so none of the super in the view chain will see the key event. The default behavior returns`false`.

<br />

|                               Parameters                                ||
|---------|----------------------------------------------------------------|
| `view`  | `WebView`: The WebView that is initiating the callback. <br /> |
| `event` | `KeyEvent`: The key event. <br />                              |

|                                                    Returns                                                    ||
|-----------|----------------------------------------------------------------------------------------------------|
| `boolean` | `true`if the host application wants to handle the key event itself, otherwise return`false` <br /> |

### shouldOverrideUrlLoading

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

```
public boolean shouldOverrideUrlLoading (WebView view, 
                WebResourceRequest request)
```

Give the host application a chance to take control when a URL is about to be loaded in the current WebView. If a WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning`true`causes the current WebView to abort loading the URL, while returning`false`causes the WebView to continue loading the URL as usual.

This callback is not called for all page navigations. In particular, this is not called for navigations which the app initiated with`loadUrl()`: this callback would not serve a purpose in this case, because the app already knows about the navigation. This callback lets the app know about navigations initiated by the web page (such as navigations initiated by JavaScript code), by the user (such as when the user taps on a link), or by an HTTP redirect (ex. if`loadUrl("foo.com")`redirects to`"bar.com"`because of HTTP 301).

**Note:** Do not call[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))with the request's URL and then return`true`. This unnecessarily cancels the current load and starts a new load with the same URL. The correct way to continue loading a given URL is to simply return`false`, without calling[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)).

**Note:**This method is not called for POST requests.

**Note:** This method may be called for subframes and with non-HTTP(S) schemes; calling[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))with such a URL will fail.

<br />

|                                      Parameters                                       ||
|-----------|----------------------------------------------------------------------------|
| `view`    | `WebView`: The WebView that is initiating the callback. <br />             |
| `request` | `WebResourceRequest`: Object containing the details of the request. <br /> |

|                                   Returns                                    ||
|-----------|-------------------------------------------------------------------|
| `boolean` | `true`to cancel the current load, otherwise return`false`. <br /> |

### shouldOverrideUrlLoading

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

```
public boolean shouldOverrideUrlLoading (WebView view, 
                String url)
```

<br />

**This method was deprecated in API level 24.**   
Use[shouldOverrideUrlLoading(WebView, WebResourceRequest)](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest))on[Build.VERSION_CODES.N](https://developer.android.com/reference/android/os/Build.VERSION_CODES#N)and above.

Give the host application a chance to take control when a URL is about to be loaded in the current WebView. If a WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning`true`causes the current WebView to abort loading the URL, while returning`false`causes the WebView to continue loading the URL as usual.

**Note:** Do not call[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))with the same URL and then return`true`. This unnecessarily cancels the current load and starts a new load with the same URL. The correct way to continue loading a given URL is to simply return`false`, without calling[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)).

**Note:**This method is not called for POST requests.

**Note:** This method may be called for subframes and with non-HTTP(S) schemes; calling[WebView.loadUrl(String)](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))with such a URL will fail.

<br />

|                               Parameters                               ||
|--------|----------------------------------------------------------------|
| `view` | `WebView`: The WebView that is initiating the callback. <br /> |
| `url`  | `String`: The URL to be loaded. <br />                         |

|                                   Returns                                    ||
|-----------|-------------------------------------------------------------------|
| `boolean` | `true`to cancel the current load, otherwise return`false`. <br /> |