Prevent webview from loading some URLs
You can use shouldOverrideUrlLoading
method of the WebViewClient
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 provided, return
true
means the host application handles the url, while returnfalse
means the current WebView handles the url.
in code:
public class MyWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading (WebView view, String url) {
if (Uri.parse(url).getHost().equals("http://Your_website_url")) {
// This is my web site, so do not override; let my WebView load the page
return false;
}
// reject anything other
return true;
}
}
mWebview.setWebViewClient(new MyWebViewClient()); //set the webviewClient