Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在webview中阻止站点_Android_Webview - Fatal编程技术网

Android 在webview中阻止站点

Android 在webview中阻止站点,android,webview,Android,Webview,在我的应用程序webview中,我想阻止一些用户不应进入的网站。例如,我如何阻止所有谷歌网站(.com.fr等),而不使用 url.contains("google"); 因为有些URL包含google这个词,但它们不会浏览到该站点。例如: 这是我的密码 web.setWebViewClient(new WebViewClient(){ @Override public void onPageStarted(WebView we

在我的应用程序webview中,我想阻止一些用户不应进入的网站。例如,我如何阻止所有谷歌网站(.com.fr等),而不使用

url.contains("google");
因为有些URL包含google这个词,但它们不会浏览到该站点。例如:

这是我的密码

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);

                }



        });

听起来很简单,但这可能是一个解决方案。使用以下命令:

if(url.startsWith("https://www.google"){
//block site
}

虽然不聪明,但仍然是有效管理url的一种方式

为什么要删除答案,然后接受使用相同代码的答案?我可以看到删除的答案。。。现在,您接受的已被删除,您已回答了自己的问题,但未被接受