我可以使用shouldInterceptRequest阻止Android中的特定呼叫吗?
我使用了以下代码我可以使用shouldInterceptRequest阻止Android中的特定呼叫吗?,android,android-intent,Android,Android Intent,我使用了以下代码 public WebResourceResponse shouldInterceptRequest(WebView view, String url) { alertsavedinternal(); //display an alert Log.d("DEBUG", "Should intercept request" +url); //log the url to console in debug mode. return null; }
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
alertsavedinternal(); //display an alert
Log.d("DEBUG", "Should intercept request" +url);
//log the url to console in debug mode.
return null;
}
但是,在显示警报的同时,我的控制台也会打印日志,此外,url也会在后台加载。如何停止加载url
请纠正我对这个函数的理解
谢谢如果在
shouldInterceptRequest
中返回null,则表示WebView将一如既往地继续加载资源
这就是为什么您看到URL仍在加载
为了拦截和阻止调用,您需要返回自己的(非空)数据