WebViewClient.ShouldOverrideUrlLoading Method

Definition

Overloads

ShouldOverrideUrlLoading(WebView, IWebResourceRequest)

Give the host application a chance to take control when a URL is about to be loaded in the current WebView.

ShouldOverrideUrlLoading(WebView, String)

Give the host application a chance to take control when a URL is about to be loaded in the current WebView.

ShouldOverrideUrlLoading(WebView, IWebResourceRequest)

Give the host application a chance to take control when a URL is about to be loaded in the current WebView.

[Android.Runtime.Register("shouldOverrideUrlLoading", "(Landroid/webkit/WebView;Landroid/webkit/WebResourceRequest;)Z", "GetShouldOverrideUrlLoading_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Handler", ApiSince=24)]
public virtual bool ShouldOverrideUrlLoading (Android.Webkit.WebView? view, Android.Webkit.IWebResourceRequest? request);
[<Android.Runtime.Register("shouldOverrideUrlLoading", "(Landroid/webkit/WebView;Landroid/webkit/WebResourceRequest;)Z", "GetShouldOverrideUrlLoading_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Handler", ApiSince=24)>]
abstract member ShouldOverrideUrlLoading : Android.Webkit.WebView * Android.Webkit.IWebResourceRequest -> bool
override this.ShouldOverrideUrlLoading : Android.Webkit.WebView * Android.Webkit.IWebResourceRequest -> bool

Parameters

view
WebView

The WebView that is initiating the callback.

request
IWebResourceRequest

Object containing the details of the request.

Returns

true to cancel the current load, otherwise return false.

Attributes

Remarks

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.

<p class="note"><b>Note:</b> Do not call WebView#loadUrl(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).

<p class="note"><b>Note:</b> This method is not called for POST requests.

<p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S) schemes; calling WebView#loadUrl(String) with such a URL will fail.

Java documentation for android.webkit.WebViewClient.shouldOverrideUrlLoading(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

ShouldOverrideUrlLoading(WebView, String)

Give the host application a chance to take control when a URL is about to be loaded in the current WebView.

[Android.Runtime.Register("shouldOverrideUrlLoading", "(Landroid/webkit/WebView;Ljava/lang/String;)Z", "GetShouldOverrideUrlLoading_Landroid_webkit_WebView_Ljava_lang_String_Handler")]
public virtual bool ShouldOverrideUrlLoading (Android.Webkit.WebView? view, string? url);
[<Android.Runtime.Register("shouldOverrideUrlLoading", "(Landroid/webkit/WebView;Ljava/lang/String;)Z", "GetShouldOverrideUrlLoading_Landroid_webkit_WebView_Ljava_lang_String_Handler")>]
abstract member ShouldOverrideUrlLoading : Android.Webkit.WebView * string -> bool
override this.ShouldOverrideUrlLoading : Android.Webkit.WebView * string -> bool

Parameters

view
WebView

The WebView that is initiating the callback.

url
String

The URL to be loaded.

Returns

true to cancel the current load, otherwise return false.

Attributes

Remarks

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.

<p class="note"><b>Note:</b> Do not call WebView#loadUrl(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).

<p class="note"><b>Note:</b> This method is not called for POST requests.

<p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S) schemes; calling WebView#loadUrl(String) with such a URL will fail.

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

Java documentation for android.webkit.WebViewClient.shouldOverrideUrlLoading(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