WebViewClient.ShouldInterceptRequest Method

Definition

Overloads

ShouldInterceptRequest(WebView, IWebResourceRequest)

Notify the host application of a resource request and allow the application to return the data.

ShouldInterceptRequest(WebView, String)
Obsolete.

Notify the host application of a resource request and allow the application to return the data.

ShouldInterceptRequest(WebView, IWebResourceRequest)

Notify the host application of a resource request and allow the application to return the data.

[Android.Runtime.Register("shouldInterceptRequest", "(Landroid/webkit/WebView;Landroid/webkit/WebResourceRequest;)Landroid/webkit/WebResourceResponse;", "GetShouldInterceptRequest_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Handler")]
public virtual Android.Webkit.WebResourceResponse? ShouldInterceptRequest (Android.Webkit.WebView? view, Android.Webkit.IWebResourceRequest? request);
[<Android.Runtime.Register("shouldInterceptRequest", "(Landroid/webkit/WebView;Landroid/webkit/WebResourceRequest;)Landroid/webkit/WebResourceResponse;", "GetShouldInterceptRequest_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Handler")>]
abstract member ShouldInterceptRequest : Android.Webkit.WebView * Android.Webkit.IWebResourceRequest -> Android.Webkit.WebResourceResponse
override this.ShouldInterceptRequest : Android.Webkit.WebView * Android.Webkit.IWebResourceRequest -> Android.Webkit.WebResourceResponse

Parameters

view
WebView

The android.webkit.WebView that is requesting the resource.

request
IWebResourceRequest

Object containing the details of the request.

Returns

A android.webkit.WebResourceResponse containing the response information or null if the WebView should load the resource itself.

Attributes

Remarks

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.

<p class="note"><b>Note:</b> 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.

<p class="note"><b>Note:</b> When Safe Browsing is enabled, these URLs still undergo Safe Browsing checks. If this is undesired, you can use WebView#setSafeBrowsingWhitelist to skip Safe Browsing checks for that host or dismiss the warning in #onSafeBrowsingHit by calling SafeBrowsingResponse#proceed.

Java documentation for android.webkit.WebViewClient.shouldInterceptRequest(android.webkit.WebView, android.webkit.WebResourceRequest).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ShouldInterceptRequest(WebView, String)

Caution

deprecated

Notify the host application of a resource request and allow the application to return the data.

[Android.Runtime.Register("shouldInterceptRequest", "(Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse;", "GetShouldInterceptRequest_Landroid_webkit_WebView_Ljava_lang_String_Handler")]
[System.Obsolete("deprecated")]
public virtual Android.Webkit.WebResourceResponse? ShouldInterceptRequest (Android.Webkit.WebView? view, string? url);
[<Android.Runtime.Register("shouldInterceptRequest", "(Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse;", "GetShouldInterceptRequest_Landroid_webkit_WebView_Ljava_lang_String_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member ShouldInterceptRequest : Android.Webkit.WebView * string -> Android.Webkit.WebResourceResponse
override this.ShouldInterceptRequest : Android.Webkit.WebView * string -> Android.Webkit.WebResourceResponse

Parameters

view
WebView

The android.webkit.WebView that is requesting the resource.

url
String

The raw url of the resource.

Returns

A android.webkit.WebResourceResponse containing the response information or null if the WebView should load the resource itself.

Attributes

Remarks

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.

<p class="note"><b>Note:</b> 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.

<p class="note"><b>Note:</b> When Safe Browsing is enabled, these URLs still undergo Safe Browsing checks. If this is undesired, you can use WebView#setSafeBrowsingWhitelist to skip Safe Browsing checks for that host or dismiss the warning in #onSafeBrowsingHit by calling SafeBrowsingResponse#proceed.

This member is deprecated. Use #shouldInterceptRequest(WebView, WebResourceRequest) shouldInterceptRequest(WebView, WebResourceRequest) instead.

Java documentation for android.webkit.WebViewClient.shouldInterceptRequest(android.webkit.WebView, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to