# WebViewClientCompat

Artifact: [androidx.webkit:webkit](https://developer.android.com/jetpack/androidx/releases/webkit) [View Source](https://cs.android.com/search?q=file:androidx/webkit/WebViewClientCompat.java+class:androidx.webkit.WebViewClientCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

*** ** * ** ***


```
class WebViewClientCompat : WebViewClient
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [android.webkit.WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient.html) ||
|   | ↳ | [androidx.webkit.WebViewClientCompat](https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat) |

*** ** * ** ***

Compatibility version of `https://developer.android.com/reference/android/webkit/WebViewClient.html`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#WebViewClientCompat()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onPageCommitVisible(android.webkit.WebView,java.lang.String)(view: https://developer.android.com/reference/android/webkit/WebView.html, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Notify the host application that `https://developer.android.com/reference/android/webkit/WebView.html` content left over from previous page navigations will no longer be drawn. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onReceivedError(android.webkit.WebView,android.webkit.WebResourceRequest,android.webkit.WebResourceError)( view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html, error: https://developer.android.com/reference/android/webkit/WebResourceError.html )` Applications are not meant to override this, and should instead override the non-final `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onReceivedError(android.webkit.WebView,android.webkit.WebResourceRequest,androidx.webkit.WebResourceErrorCompat)` method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onReceivedError(android.webkit.WebView,android.webkit.WebResourceRequest,androidx.webkit.WebResourceErrorCompat)( view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html, error: https://developer.android.com/reference/kotlin/androidx/webkit/WebResourceErrorCompat )` Report web resource loading error to the host application. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onReceivedHttpError(android.webkit.WebView,android.webkit.WebResourceRequest,android.webkit.WebResourceResponse)( view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html, errorResponse: https://developer.android.com/reference/android/webkit/WebResourceResponse.html )` Notify the host application that an HTTP error has been received from the server while loading a resource. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onSafeBrowsingHit(android.webkit.WebView,android.webkit.WebResourceRequest,int,androidx.webkit.SafeBrowsingResponseCompat)( view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html, threatType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, callback: https://developer.android.com/reference/kotlin/androidx/webkit/SafeBrowsingResponseCompat )` Notify the host application that a loading URL has been flagged by Safe Browsing. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#O_MR1) https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onSafeBrowsingHit(android.webkit.WebView,android.webkit.WebResourceRequest,int,android.webkit.SafeBrowsingResponse)( view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html, threatType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, response: https://developer.android.com/reference/android/webkit/SafeBrowsingResponse.html )` Applications are not meant to override this, and should instead override the non-final `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onSafeBrowsingHit(android.webkit.WebView,android.webkit.WebResourceRequest,int,androidx.webkit.SafeBrowsingResponseCompat)` method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#shouldOverrideUrlLoading(android.webkit.WebView,android.webkit.WebResourceRequest)(view: https://developer.android.com/reference/android/webkit/WebView.html, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html)` Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. |

### Inherited Constants

From [android.webkit.WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient.html) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_AUTHENTICATION = -4` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_BAD_URL = -12` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_CONNECT = -6` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_FAILED_SSL_HANDSHAKE = -11` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_FILE = -13` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_FILE_NOT_FOUND = -14` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_HOST_LOOKUP = -2` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_IO = -7` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_PROXY_AUTHENTICATION = -5` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_REDIRECT_LOOP = -9` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_TIMEOUT = -8` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_TOO_MANY_REQUESTS = -15` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_UNKNOWN = -1` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_UNSAFE_RESOURCE = -16` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_UNSUPPORTED_AUTH_SCHEME = -3` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#ERROR_UNSUPPORTED_SCHEME = -10` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#SAFE_BROWSING_THREAT_BILLING = 4` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#SAFE_BROWSING_THREAT_MALWARE = 1` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#SAFE_BROWSING_THREAT_PHISHING = 2` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#SAFE_BROWSING_THREAT_UNKNOWN = 0` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE = 3`

### Inherited functions

From [android.webkit.WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#doUpdateVisitedHistory(android.webkit.WebView, java.lang.String, boolean)(view: https://developer.android.com/reference/android/webkit/WebView.html!, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, isReload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onFormResubmission(android.webkit.WebView, android.os.Message, android.os.Message)(view: https://developer.android.com/reference/android/webkit/WebView.html!, dontResend: https://developer.android.com/reference/android/os/Message.html!, resend: https://developer.android.com/reference/android/os/Message.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onLoadResource(android.webkit.WebView, java.lang.String)(view: https://developer.android.com/reference/android/webkit/WebView.html!, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onPageFinished(android.webkit.WebView, java.lang.String)(view: https://developer.android.com/reference/android/webkit/WebView.html!, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap)(view: https://developer.android.com/reference/android/webkit/WebView.html!, url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, favicon: https://developer.android.com/reference/android/graphics/Bitmap.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest)(view: https://developer.android.com/reference/android/webkit/WebView.html!, request: https://developer.android.com/reference/android/webkit/ClientCertRequest.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String)(
view: https://developer.android.com/reference/android/webkit/WebView.html!,
handler: https://developer.android.com/reference/android/webkit/HttpAuthHandler.html!,
host: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
realm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String)(
view: https://developer.android.com/reference/android/webkit/WebView.html!,
realm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
account: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
args: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError)(
view: https://developer.android.com/reference/android/webkit/WebView.html!,
handler: https://developer.android.com/reference/android/webkit/SslErrorHandler.html!,
error: https://developer.android.com/reference/android/net/http/SslError.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail)(view: https://developer.android.com/reference/android/webkit/WebView.html!, detail: https://developer.android.com/reference/android/webkit/RenderProcessGoneDetail.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onScaleChanged(android.webkit.WebView, float, float)(view: https://developer.android.com/reference/android/webkit/WebView.html!, oldScale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, newScale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message)(view: https://developer.android.com/reference/android/webkit/WebView.html!, cancelMsg: https://developer.android.com/reference/android/os/Message.html!, continueMsg: https://developer.android.com/reference/android/os/Message.html!)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent)(view: https://developer.android.com/reference/android/webkit/WebView.html!, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://developer.android.com/reference/android/webkit/WebResourceResponse.html!` `https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldInterceptRequest(android.webkit.WebView, android.webkit.WebResourceRequest)(view: https://developer.android.com/reference/android/webkit/WebView.html!, request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideKeyEvent(android.webkit.WebView, android.view.KeyEvent)(view: https://developer.android.com/reference/android/webkit/WebView.html!, event: https://developer.android.com/reference/android/view/KeyEvent.html!)`

## Public constructors

### WebViewClientCompat

Added in 1.1.0

```
WebViewClientCompat()
```

## Public functions

### onPageCommitVisible

```
@UiThread
fun onPageCommitVisible(view: WebView, url: String): Unit
```

Notify the host application that `https://developer.android.com/reference/android/webkit/WebView.html` 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 `https://developer.android.com/reference/android/webkit/WebView.html` visible, ensuring that no stale content is shown. It is called at the earliest point at which it can be guaranteed that `https://developer.android.com/reference/android/webkit/WebView.html#onDraw(android.graphics.Canvas)` will no longer draw any content from previous navigations. The next draw will display either the `https://developer.android.com/reference/android/webkit/WebView.html#setBackgroundColor(int)` of the `https://developer.android.com/reference/android/webkit/WebView.html`, 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 `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#postVisualStateCallback(android.webkit.WebView,long,androidx.webkit.WebViewCompat.VisualStateCallback)`.

Please note that all the conditions and recommendations applicable to `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#postVisualStateCallback(android.webkit.WebView,long,androidx.webkit.WebViewCompat.VisualStateCallback)` also apply to this API.

This callback is only called for main frame navigations.

This method is called only if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#VISUAL_STATE_CALLBACK()` is supported. You can check whether that flag is supported using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/webkit/WebView.html` | The `https://developer.android.com/reference/android/webkit/WebView.html` for which the navigation occurred. |
| `url: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The URL corresponding to the page navigation that triggered this callback. |

### onReceivedError

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
fun onReceivedError(
    view: WebView,
    request: WebResourceRequest,
    error: WebResourceError
): Unit
```

Applications are not meant to override this, and should instead override the non-final `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onReceivedError(android.webkit.WebView,android.webkit.WebResourceRequest,androidx.webkit.WebResourceErrorCompat)` method.

### onReceivedError

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@UiThread
fun onReceivedError(
    view: WebView,
    request: WebResourceRequest,
    error: WebResourceErrorCompat
): Unit
```

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.

This method is called only if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#RECEIVE_WEB_RESOURCE_ERROR()` is supported. You can check whether that flag is supported using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView that is initiating the callback. |
| `request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html` | The originating request. |
| `error: https://developer.android.com/reference/kotlin/androidx/webkit/WebResourceErrorCompat` | Information about the error occurred. |

### onReceivedHttpError

```
@UiThread
fun onReceivedHttpError(
    view: WebView,
    request: WebResourceRequest,
    errorResponse: WebResourceResponse
): Unit
```

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.

This method is called only if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#RECEIVE_HTTP_ERROR()` is supported. You can check whether that flag is supported using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView that is initiating the callback. |
| `request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html` | The originating request. |
| `errorResponse: https://developer.android.com/reference/android/webkit/WebResourceResponse.html` | Information about the error occurred. |

### onSafeBrowsingHit

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@UiThread
fun onSafeBrowsingHit(
    view: WebView,
    request: WebResourceRequest,
    threatType: Int,
    callback: SafeBrowsingResponseCompat
): Unit
```

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 `https://developer.android.com/reference/kotlin/androidx/webkit/SafeBrowsingResponseCompat#backToSafety(boolean)` or `https://developer.android.com/reference/kotlin/androidx/webkit/SafeBrowsingResponseCompat#proceed(boolean)`, depending on user response.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView that hit the malicious resource. |
| `request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html` | Object containing the details of the request. |
| `threatType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The reason the resource was caught by Safe Browsing, corresponding to a `SAFE_BROWSING_THREAT_*` value. Value is one of the following: - `WebViewClient.SAFE_BROWSING_THREAT_UNKNOWN` - `WebViewClient.SAFE_BROWSING_THREAT_MALWARE` - `WebViewClient.SAFE_BROWSING_THREAT_PHISHING` - `WebViewClient.SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE` - `WebViewClient.SAFE_BROWSING_THREAT_BILLING` <br /> |
| `callback: https://developer.android.com/reference/kotlin/androidx/webkit/SafeBrowsingResponseCompat` | Applications must invoke one of the callback methods. |

### onSafeBrowsingHit

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresApi(value = Build.VERSION_CODES.O_MR1)
fun onSafeBrowsingHit(
    view: WebView,
    request: WebResourceRequest,
    threatType: Int,
    response: SafeBrowsingResponse
): Unit
```

Applications are not meant to override this, and should instead override the non-final `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewClientCompat#onSafeBrowsingHit(android.webkit.WebView,android.webkit.WebResourceRequest,int,androidx.webkit.SafeBrowsingResponseCompat)` method.

### shouldOverrideUrlLoading

```
@UiThread
fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean
```

Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the url. If WebViewClient is provided, return `true` means the host application handles the url, while return `false` means the current WebView handles the url.

Notes:

- This method is not called for requests using the POST "method".
- This method is also called for subframes with non-http schemes, thus it is strongly disadvised to unconditionally call `https://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)` with the request's url from inside the method and then return `true`, as this will make WebView to attempt loading a non-http url, and thus fail.

This method is called only if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SHOULD_OVERRIDE_WITH_REDIRECTS()` is supported. You can check whether that flag is supported using `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/webkit/WebView.html` | The WebView that is initiating the callback. |
| `request: https://developer.android.com/reference/android/webkit/WebResourceRequest.html` | Object containing the details of the request. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the host application wants to leave the current WebView and handle the url itself, otherwise return `false`. |