WebViewClient webViewClient = new WebViewClient() {
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
//拦截
Log.d("拦截Url:{}",url);
if (url.contains("需要拦截的url或者js效果")) {
return new WebResourceResponse("text/plain", "UTF-8", null);//返回给h5的文件读取
}
return super.shouldInterceptRequest(view, url);
}
}