Reputation: 635
In my apps webview i want to block some sites that users should not enter. For example how can i block all google sites (.com .fr etc.) without using
url.contains("google");
because some urls contain the word google but they dont browse to the site. For example: https://www.bing.com/search?q=google
Here is my code
web.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView webView, String webUrl, Bitmap favicon) {
if(webUrl.contains("google")){//not works good
//block
}
super.onPageStarted(webView, webUrl, favicon);
}
});
Upvotes: 3
Views: 549
Reputation: 635
Sounds simple but it could be a solution. Use this:
if(url.startsWith("https://www.google"){
//block site
}
Not smart but remains a way to effectively manage url
Upvotes: 4