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

# WebChromeClient

*** ** * ** ***


`
public


class
WebChromeClient
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/webkit/WebChromeClient.CustomViewCallback` A callback interface used by the host application to notify the current page that its custom view has been dismissed. |
| ` class` | `https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams` Parameters used in the `https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback<android.net.Uri[]>,%20android.webkit.WebChromeClient.FileChooserParams)` method. |

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

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#getDefaultVideoPoster()() ` When not playing, video elements are represented by a 'poster' image. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#getVideoLoadingProgressView()() ` Obtains a View to be displayed while buffering of full screen video is taking place. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#getVisitedHistory(android.webkit.ValueCallback<java.lang.String[]>)(https://developer.android.com/reference/android/webkit/ValueCallback<https://developer.android.com/reference/java/lang/String> callback) ` Obtains a list of all visited history items, used for link coloring |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)(https://developer.android.com/reference/android/webkit/WebView window) ` Notify the host application to close the given WebView and remove it from the view system if necessary. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)(https://developer.android.com/reference/android/webkit/ConsoleMessage consoleMessage) ` Report a JavaScript console message to the host application. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/java/lang/String message, int lineNumber, https://developer.android.com/reference/java/lang/String sourceID) ` *This method was deprecated in API level 15. Use `https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)` instead.* |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)(https://developer.android.com/reference/android/webkit/WebView view, boolean isDialog, boolean isUserGesture, https://developer.android.com/reference/android/os/Message resultMsg) ` Request the host application to create a new window. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onExceededDatabaseQuota(java.lang.String,%20java.lang.String,%20long,%20long,%20long,%20android.webkit.WebStorage.QuotaUpdater)(https://developer.android.com/reference/java/lang/String url, https://developer.android.com/reference/java/lang/String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, https://developer.android.com/reference/android/webkit/WebStorage.QuotaUpdater quotaUpdater) ` *This method was deprecated in API level 19. This method is no longer called; WebView now uses the HTML5 / JavaScript Quota Management API.* |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()() ` Notify the host application that a request for Geolocation permissions, made with a previous call to `https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)` has been canceled. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)(https://developer.android.com/reference/java/lang/String origin, https://developer.android.com/reference/android/webkit/GeolocationPermissions.Callback callback) ` Notify the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()() ` Notify the host application that the current page has exited full screen mode. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String url, https://developer.android.com/reference/java/lang/String message, https://developer.android.com/reference/android/webkit/JsResult result) ` Notify the host application that the web page wants to display a JavaScript `alert()` dialog. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String url, https://developer.android.com/reference/java/lang/String message, https://developer.android.com/reference/android/webkit/JsResult result) ` Notify the host application that the web page wants to confirm navigation from JavaScript `onbeforeunload`. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String url, https://developer.android.com/reference/java/lang/String message, https://developer.android.com/reference/android/webkit/JsResult result) ` Notify the host application that the web page wants to display a JavaScript `confirm()` dialog. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String url, https://developer.android.com/reference/java/lang/String message, https://developer.android.com/reference/java/lang/String defaultValue, https://developer.android.com/reference/android/webkit/JsPromptResult result) ` Notify the host application that the web page wants to display a JavaScript `prompt()` dialog. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onJsTimeout()() ` *This method was deprecated in API level 17. This method is no longer supported and will not be invoked.* |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)(https://developer.android.com/reference/android/webkit/PermissionRequest request) ` Notify the host application that web content is requesting permission to access the specified resources and the permission currently isn't granted or denied. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)(https://developer.android.com/reference/android/webkit/PermissionRequest request) ` Notify the host application that the given permission request has been canceled. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)(https://developer.android.com/reference/android/webkit/WebView view, int newProgress) ` Tell the host application the current progress of loading a page. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/android/graphics/Bitmap icon) ` Notify the host application of a new favicon for the current page. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String title) ` Notify the host application of a change in the document title. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)(https://developer.android.com/reference/android/webkit/WebView view, https://developer.android.com/reference/java/lang/String url, boolean precomposed) ` Notify the host application of the url for an apple-touch-icon. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView)(https://developer.android.com/reference/android/webkit/WebView view) ` Request display and focus for this WebView. |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20int,%20android.webkit.WebChromeClient.CustomViewCallback)(https://developer.android.com/reference/android/view/View view, int requestedOrientation, https://developer.android.com/reference/android/webkit/WebChromeClient.CustomViewCallback callback) ` *This method was deprecated in API level 18. This method supports the obsolete plugin mechanism, and will not be invoked in future* |
| ` void` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/android/webkit/WebChromeClient.CustomViewCallback callback) ` Notify the host application that the current page has entered full screen mode. |
| ` boolean` | ` https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback<android.net.Uri[]>,%20android.webkit.WebChromeClient.FileChooserParams)(https://developer.android.com/reference/android/webkit/WebView webView, https://developer.android.com/reference/android/webkit/ValueCallback<https://developer.android.com/reference/android/net/Uri> filePathCallback, https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams fileChooserParams) ` Asks the client app to show a file chooser. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### WebChromeClient

```
public WebChromeClient ()
```

<br />

<br />

## Public methods

### getDefaultVideoPoster

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

```
public Bitmap getDefaultVideoPoster ()
```

When not playing, video elements are represented by a 'poster' image. The
image to use can be specified by the poster attribute of the video tag in
HTML. If the attribute is absent, then a default poster will be used. This
method allows the ChromeClient to provide that default image.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | Bitmap The image to use as a default poster, or `null` if no such image is available. <br /> |

### getVideoLoadingProgressView

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

```
public View getVideoLoadingProgressView ()
```

Obtains a View to be displayed while buffering of full screen video is taking
place. The host application can override this method to provide a View
containing a spinner or similar.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The View to be displayed whilst the video is loading. This value may be `null`. <br /> |

### getVisitedHistory

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

```
public void getVisitedHistory (ValueCallback<String[]> callback)
```

Obtains a list of all visited history items, used for link coloring

<br />

| Parameters ||
|---|---|
| `callback` | `ValueCallback` <br /> |

### onCloseWindow

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

```
public void onCloseWindow (WebView window)
```

Notify the host application to close the given WebView and remove it
from the view system if necessary. At this point, WebCore has stopped
any loading in this window and has removed any cross-scripting ability
in javascript.


As with `https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)`, the application should ensure that any
URL or security indicator displayed is updated so that the user can tell
that the page they were interacting with has been closed.

<br />

| Parameters ||
|---|---|
| `window` | `WebView`: The WebView that needs to be closed. <br /> |

### onConsoleMessage

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

```
public boolean onConsoleMessage (ConsoleMessage consoleMessage)
```

Report a JavaScript console message to the host application. The ChromeClient
should override this to process the log message as they see fit.

<br />

| Parameters ||
|---|---|
| `consoleMessage` | `ConsoleMessage`: Object containing details of the console message. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the message is handled by the client. <br /> |

### onConsoleMessage

Added in [API level 7](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 onConsoleMessage (String message, 
                int lineNumber, 
                String sourceID)
```


**This method was deprecated
in API level 15.**   

Use `https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)`
instead.

Report a JavaScript error message to the host application. The ChromeClient
should override this to process the log message as they see fit.

<br />

| Parameters ||
|---|---|
| `message` | `String`: The error message to report. <br /> |
| `lineNumber` | `int`: The line number of the error. <br /> |
| `sourceID` | `String`: The name of the source file that caused the error. <br /> |

### onCreateWindow

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

```
public boolean onCreateWindow (WebView view, 
                boolean isDialog, 
                boolean isUserGesture, 
                Message resultMsg)
```

Request the host application to create a new window. If the host
application chooses to honor this request, it should return `true` from
this method, create a new WebView to host the window, insert it into the
View system and send the supplied resultMsg message to its target with
the new WebView as an argument. If the host application chooses not to
honor the request, it should return `false` from this method. The default
implementation of this method does nothing and hence returns `false`.


Applications should typically not allow windows to be created when the
`isUserGesture` flag is false, as this may be an unwanted popup.


Applications should be careful how they display the new window: don't simply
overlay it over the existing WebView as this may mislead the user about which
site they are viewing. If your application displays the URL of the main page,
make sure to also display the URL of the new window in a similar fashion. If
your application does not display URLs, consider disallowing the creation of
new windows entirely.

**Note:** There is no trustworthy way to tell which page
requested the new window: the request might originate from a third-party iframe
inside the WebView.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView from which the request for a new window originated. <br /> |
| `isDialog` | `boolean`: `true` if the new window should be a dialog, rather than a full-size window. <br /> |
| `isUserGesture` | `boolean`: `true` if the request was initiated by a user gesture, such as the user clicking a link. <br /> |
| `resultMsg` | `Message`: The message to send when once a new WebView has been created. resultMsg.obj is a `https://developer.android.com/reference/android/webkit/WebView.WebViewTransport` object. This should be used to transport the new WebView, by calling `https://developer.android.com/reference/android/webkit/WebView.WebViewTransport#setWebView(android.webkit.WebView)`. <br /> |

| Returns ||
|---|---|
| `boolean` | This method should return `true` if the host application will create a new window, in which case resultMsg should be sent to its target. Otherwise, this method should return `false`. Returning `false` from this method but also sending resultMsg will result in undefined behavior. <br /> |

### onExceededDatabaseQuota

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

```
public void onExceededDatabaseQuota (String url, 
                String databaseIdentifier, 
                long quota, 
                long estimatedDatabaseSize, 
                long totalQuota, 
                WebStorage.QuotaUpdater quotaUpdater)
```


**This method was deprecated
in API level 19.**   

This method is no longer called; WebView now uses the HTML5 / JavaScript Quota
Management API.

Tell the client that the quota has been exceeded for the Web SQL Database
API for a particular origin and request a new quota. The client must
respond by invoking the
`https://developer.android.com/reference/android/webkit/WebStorage.QuotaUpdater#updateQuota(long)`
method of the supplied `https://developer.android.com/reference/android/webkit/WebStorage.QuotaUpdater` instance. The
minimum value that can be set for the new quota is the current quota. The
default implementation responds with the current quota, so the quota will
not be increased.

<br />

| Parameters ||
|---|---|
| `url` | `String`: The URL of the page that triggered the notification <br /> |
| `databaseIdentifier` | `String`: The identifier of the database where the quota was exceeded. <br /> |
| `quota` | `long`: The quota for the origin, in bytes <br /> |
| `estimatedDatabaseSize` | `long`: The estimated size of the offending database, in bytes <br /> |
| `totalQuota` | `long`: The total quota for all origins, in bytes <br /> |
| `quotaUpdater` | `WebStorage.QuotaUpdater`: An instance of `https://developer.android.com/reference/android/webkit/WebStorage.QuotaUpdater` which must be used to inform the WebView of the new quota. <br /> |

### onGeolocationPermissionsHidePrompt

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

```
public void onGeolocationPermissionsHidePrompt ()
```

Notify the host application that a request for Geolocation permissions,
made with a previous call to
`https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)`
has been canceled. Any related UI should therefore be hidden.

<br />

### onGeolocationPermissionsShowPrompt

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

```
public void onGeolocationPermissionsShowPrompt (String origin, 
                GeolocationPermissions.Callback callback)
```

Notify the host application that web content from the specified origin
is attempting to use the Geolocation API, but no permission state is
currently set for that origin. The host application should invoke the
specified callback with the desired permission state. See
`https://developer.android.com/reference/android/webkit/GeolocationPermissions` for details.

Note that for applications targeting Android N and later SDKs
(API level \> `https://developer.android.com/reference/android/os/Build.VERSION_CODES#M`)
this method is only called for requests originating from secure
origins such as https. On non-secure origins geolocation requests
are automatically denied.

<br />

| Parameters ||
|---|---|
| `origin` | `String`: The origin of the web content attempting to use the Geolocation API. <br /> |
| `callback` | `GeolocationPermissions.Callback`: The callback to use to set the permission state for the origin. <br /> |

### onHideCustomView

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

```
public void onHideCustomView ()
```

Notify the host application that the current page has exited full screen mode. The host
application must hide the custom View (the View which was previously passed to `https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)`). After this call, web
content will render in the original WebView again.

**Note:** if overriding this method, the application must also override
`https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)`.

<br />

### onJsAlert

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

```
public boolean onJsAlert (WebView view, 
                String url, 
                String message, 
                JsResult result)
```

Notify the host application that the web page wants to display a
JavaScript `alert()` dialog.

The default behavior if this method returns `false` or is not
overridden is to show a dialog containing the alert message and suspend
JavaScript execution until the dialog is dismissed.

To show a custom dialog, the app should return `true` from this
method, in which case the default dialog will not be shown and JavaScript
execution will be suspended. The app should call
`JsResult.confirm()` when the custom dialog is dismissed such that
JavaScript execution can be resumed.

To suppress the dialog and allow JavaScript execution to
continue, call `JsResult.confirm()` immediately and then return
`true`.

Note that if the `https://developer.android.com/reference/android/webkit/WebChromeClient` is set to be `null`,
or if `https://developer.android.com/reference/android/webkit/WebChromeClient` is not set at all, the default dialog will
be suppressed and Javascript execution will continue immediately.

Note that the default dialog does not inherit the `https://developer.android.com/reference/android/view/Display#FLAG_SECURE` flag from the parent window.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `url` | `String`: The url of the page requesting the dialog. <br /> |
| `message` | `String`: Message to be displayed in the window. <br /> |
| `result` | `JsResult`: A JsResult to confirm that the user closed the window. <br /> |

| Returns ||
|---|---|
| `boolean` | boolean `true` if the request is handled or ignored. `false` if WebView needs to show the default dialog. <br /> |

### onJsBeforeUnload

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

```
public boolean onJsBeforeUnload (WebView view, 
                String url, 
                String message, 
                JsResult result)
```

Notify the host application that the web page wants to confirm navigation
from JavaScript `onbeforeunload`.

The default behavior if this method returns `false` or is not
overridden is to show a dialog containing the message and suspend
JavaScript execution until the dialog is dismissed. The default dialog
will continue the navigation if the user confirms the navigation, and
will stop the navigation if the user wants to stay on the current page.

To show a custom dialog, the app should return `true` from this
method, in which case the default dialog will not be shown and JavaScript
execution will be suspended. When the custom dialog is dismissed, the
app should call `JsResult.confirm()` to continue the navigation or,
`JsResult.cancel()` to stay on the current page.

To suppress the dialog and allow JavaScript execution to continue,
call `JsResult.confirm()` or `JsResult.cancel()` immediately
and then return `true`.

Note that if the `https://developer.android.com/reference/android/webkit/WebChromeClient` is set to be `null`,
or if `https://developer.android.com/reference/android/webkit/WebChromeClient` is not set at all, the default dialog will
be suppressed and the navigation will be resumed immediately.

Note that the default dialog does not inherit the `https://developer.android.com/reference/android/view/Display#FLAG_SECURE` flag from the parent window.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `url` | `String`: The url of the page requesting the dialog. <br /> |
| `message` | `String`: Message to be displayed in the window. <br /> |
| `result` | `JsResult`: A JsResult used to send the user's response to javascript. <br /> |

| Returns ||
|---|---|
| `boolean` | boolean `true` if the request is handled or ignored. `false` if WebView needs to show the default dialog. <br /> |

### onJsConfirm

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

```
public boolean onJsConfirm (WebView view, 
                String url, 
                String message, 
                JsResult result)
```

Notify the host application that the web page wants to display a
JavaScript `confirm()` dialog.

The default behavior if this method returns `false` or is not
overridden is to show a dialog containing the message and suspend
JavaScript execution until the dialog is dismissed. The default dialog
will return `true` to the JavaScript `confirm()` code when
the user presses the 'confirm' button, and will return `false` to
the JavaScript code when the user presses the 'cancel' button or
dismisses the dialog.

To show a custom dialog, the app should return `true` from this
method, in which case the default dialog will not be shown and JavaScript
execution will be suspended. The app should call
`JsResult.confirm()` or `JsResult.cancel()` when the custom
dialog is dismissed.

To suppress the dialog and allow JavaScript execution to continue,
call `JsResult.confirm()` or `JsResult.cancel()` immediately
and then return `true`.

Note that if the `https://developer.android.com/reference/android/webkit/WebChromeClient` is set to be `null`,
or if `https://developer.android.com/reference/android/webkit/WebChromeClient` is not set at all, the default dialog will
be suppressed and the default value of `false` will be returned to
the JavaScript code immediately.

Note that the default dialog does not inherit the `https://developer.android.com/reference/android/view/Display#FLAG_SECURE` flag from the parent window.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `url` | `String`: The url of the page requesting the dialog. <br /> |
| `message` | `String`: Message to be displayed in the window. <br /> |
| `result` | `JsResult`: A JsResult used to send the user's response to javascript. <br /> |

| Returns ||
|---|---|
| `boolean` | boolean `true` if the request is handled or ignored. `false` if WebView needs to show the default dialog. <br /> |

### onJsPrompt

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

```
public boolean onJsPrompt (WebView view, 
                String url, 
                String message, 
                String defaultValue, 
                JsPromptResult result)
```

Notify the host application that the web page wants to display a
JavaScript `prompt()` dialog.

The default behavior if this method returns `false` or is not
overridden is to show a dialog containing the message and suspend
JavaScript execution until the dialog is dismissed. Once the dialog is
dismissed, JavaScript `prompt()` will return the string that the
user typed in, or null if the user presses the 'cancel' button.

To show a custom dialog, the app should return `true` from this
method, in which case the default dialog will not be shown and JavaScript
execution will be suspended. The app should call
`JsPromptResult.confirm(result)` when the custom dialog is
dismissed.

To suppress the dialog and allow JavaScript execution to continue,
call `JsPromptResult.confirm(result)` immediately and then
return `true`.

Note that if the `https://developer.android.com/reference/android/webkit/WebChromeClient` is set to be `null`,
or if `https://developer.android.com/reference/android/webkit/WebChromeClient` is not set at all, the default dialog will
be suppressed and `null` will be returned to the JavaScript code
immediately.

Note that the default dialog does not inherit the `https://developer.android.com/reference/android/view/Display#FLAG_SECURE` flag from the parent window.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `url` | `String`: The url of the page requesting the dialog. <br /> |
| `message` | `String`: Message to be displayed in the window. <br /> |
| `defaultValue` | `String`: The default value displayed in the prompt dialog. <br /> |
| `result` | `JsPromptResult`: A JsPromptResult used to send the user's reponse to javascript. <br /> |

| Returns ||
|---|---|
| `boolean` | boolean `true` if the request is handled or ignored. `false` if WebView needs to show the default dialog. <br /> |

### onJsTimeout

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

```
public boolean onJsTimeout ()
```


**This method was deprecated
in API level 17.**   

This method is no longer supported and will not be invoked.

Tell the client that a JavaScript execution timeout has occured. And the
client may decide whether or not to interrupt the execution. If the
client returns `true`, the JavaScript will be interrupted. If the client
returns `false`, the execution will continue. Note that in the case of
continuing execution, the timeout counter will be reset, and the callback
will continue to occur if the script does not finish at the next check
point.

<br />

| Returns ||
|---|---|
| `boolean` | boolean Whether the JavaScript execution should be interrupted. <br /> |

### onPermissionRequest

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

```
public void onPermissionRequest (PermissionRequest request)
```

Notify the host application that web content is requesting permission to
access the specified resources and the permission currently isn't granted
or denied. The host application must invoke `https://developer.android.com/reference/android/webkit/PermissionRequest#grant(java.lang.String[])`
or `https://developer.android.com/reference/android/webkit/PermissionRequest#deny()`.

If this method isn't overridden, the permission is denied.

<br />

| Parameters ||
|---|---|
| `request` | `PermissionRequest`: the PermissionRequest from current web content. <br /> |

### onPermissionRequestCanceled

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

```
public void onPermissionRequestCanceled (PermissionRequest request)
```

Notify the host application that the given permission request
has been canceled. Any related UI should therefore be hidden.

<br />

| Parameters ||
|---|---|
| `request` | `PermissionRequest`: the PermissionRequest that needs be canceled. <br /> |

### onProgressChanged

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

```
public void onProgressChanged (WebView view, 
                int newProgress)
```

Tell the host application the current progress of loading a page.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `newProgress` | `int`: Current page loading progress, represented by an integer between 0 and 100. <br /> |

### onReceivedIcon

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

```
public void onReceivedIcon (WebView view, 
                Bitmap icon)
```

Notify the host application of a new favicon for the current page.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `icon` | `Bitmap`: A Bitmap containing the favicon for the current page. <br /> |

### onReceivedTitle

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

```
public void onReceivedTitle (WebView view, 
                String title)
```

Notify the host application of a change in the document title.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `title` | `String`: A String containing the new title of the document. <br /> |

### onReceivedTouchIconUrl

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

```
public void onReceivedTouchIconUrl (WebView view, 
                String url, 
                boolean precomposed)
```

Notify the host application of the url for an apple-touch-icon.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that initiated the callback. <br /> |
| `url` | `String`: The icon url. <br /> |
| `precomposed` | `boolean`: `true` if the url is for a precomposed touch icon. <br /> |

### onRequestFocus

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

```
public void onRequestFocus (WebView view)
```

Request display and focus for this WebView. This may happen due to
another WebView opening a link in this WebView and requesting that this
WebView be displayed.

<br />

| Parameters ||
|---|---|
| `view` | `WebView`: The WebView that needs to be focused. <br /> |

### onShowCustomView

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

```
public void onShowCustomView (View view, 
                int requestedOrientation, 
                WebChromeClient.CustomViewCallback callback)
```


**This method was deprecated
in API level 18.**   

This method supports the obsolete plugin mechanism,
and will not be invoked in future

Notify the host application that the current page would
like to show a custom View in a particular orientation.

<br />

| Parameters ||
|---|---|
| `view` | `View`: is the View object to be shown. <br /> |
| `requestedOrientation` | `int`: An orientation constant as used in `https://developer.android.com/reference/android/content/pm/ActivityInfo#screenOrientation`. <br /> |
| `callback` | `WebChromeClient.CustomViewCallback`: is the callback to be invoked if and when the view is dismissed. <br /> |

### onShowCustomView

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

```
public void onShowCustomView (View view, 
                WebChromeClient.CustomViewCallback callback)
```

Notify the host application that the current page has entered full screen mode. After this
call, web content will no longer be rendered in the WebView, but will instead be rendered
in `view`. The host application should add this View to a Window which is configured
with `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_FULLSCREEN` flag in order to
actually display this web content full screen.

The application may explicitly exit fullscreen mode by invoking `callback` (ex. when
the user presses the back button). However, this is generally not necessary as the web page
will often show its own UI to close out of fullscreen. Regardless of how the WebView exits
fullscreen mode, WebView will invoke `https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()`, signaling for the
application to remove the custom View.

If this method is not overridden, WebView will report to the web page it does not support
fullscreen mode and will not honor the web page's request to run in fullscreen mode.

**Note:** if overriding this method, the application must also override
`https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()`.

<br />

| Parameters ||
|---|---|
| `view` | `View`: is the View object to be shown. <br /> |
| `callback` | `WebChromeClient.CustomViewCallback`: invoke this callback to request the page to exit full screen mode. <br /> |

### onShowFileChooser

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

```
public boolean onShowFileChooser (WebView webView, 
                ValueCallback<Uri[]> filePathCallback, 
                WebChromeClient.FileChooserParams fileChooserParams)
```

Asks the client app to show a file chooser. The web page has requested to either upload or
save a file, such as from a 'file' input in an HTML form or due to a JavaScript API call. The
client app can decide whether to show the user a file chooser dialog or to programmatically
handle the request. This can be invoked both for uploads and downloads, and it can also be
invoked for single files, multiple files, or entire folders. Client apps should check `fileChooserParams` for details about what type of file is being requested.

To show the user a file chooser dialog, override this callback to return `true` and
store the `filePathCallback` in a variable. Present the dialog to the user and when
they reply, invoke the callback with a URI which points to the file. Make sure to check the
`fileChooserParams` in order to show appropriate options in the file chooser dialog,
such as automatically filtering by relevant file type (see `https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams#getAcceptTypes()`).

To handle each request programmatically, respond to this callback with `true`. You
can invoke `filePathCallback` with `null` in order to cancel the request or you
can invoke the callback with a URI to actual file or folder.

The default behavior is that WebView will cancel all file requests.

**Note:** WebView does not enforce any restrictions on
the chosen file(s). WebView can access all files that your app can access.
In case the file(s) are chosen through an untrusted source such as a third-party
app, it is your own app's responsibility to check what the returned Uris
refer to before calling the `filePathCallback`. See
`https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams#createIntent()` and `https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams#parseResult(int,%20android.content.Intent)` for more
details.

<br />

| Parameters ||
|---|---|
| `webView` | `WebView`: The WebView instance that is initiating the request. <br /> |
| `filePathCallback` | `ValueCallback`: Invoke this callback to supply the list of paths to files to upload, or `null` to cancel. Must only be called if the `https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback<android.net.Uri[]>,%20android.webkit.WebChromeClient.FileChooserParams)` implementation returns `true`. <br /> |
| `fileChooserParams` | `WebChromeClient.FileChooserParams`: Describes the mode of file chooser to be opened, and options to be used with it. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if filePathCallback will be invoked, `false` to use default handling. <br /> |

**See also:**

- `https://developer.android.com/reference/android/webkit/WebChromeClient.FileChooserParams`