Javascript 检查webview';s是否应该呼叫InterceptRequest?

Javascript 检查webview';s是否应该呼叫InterceptRequest?,javascript,android,webview,Javascript,Android,Webview,我有一个android应用程序,我使用webview加载一个html文件,该文件调用javascript函数,如下所示: 爪哇: html: 我需要的是,我想检查方法是否应该调用InterceptRequest,因为在我的一些请求中,它没有被触发。 如果请求未被拦截,我想显示一些消息。 有没有办法先知道该方法是否应该被触发?shouldInterceptRequest:该回调用于各种URL方案(例如http、数据、文件等),而不仅仅是那些通过网络发送请求的方案。对于javascript:url、

我有一个android应用程序,我使用webview加载一个html文件,该文件调用javascript函数,如下所示:

爪哇:

html:

我需要的是,我想检查方法是否应该调用InterceptRequest,因为在我的一些请求中,它没有被触发。 如果请求未被拦截,我想显示一些消息。
有没有办法先知道该方法是否应该被触发?

shouldInterceptRequest:该回调用于各种URL方案(例如http、数据、文件等),而不仅仅是那些通过网络发送请求的方案。对于javascript:url、blob:url或通过file:///android_asset/ 或file:///android_res/ 网址


你确定吗?因为上面的代码是一个工作代码。它只在我无法理解的特定场景中失败。因此,问题就来了。注:js库从服务器获取信息。是的,我。我确信您可以查看开发人员页面()
 mWebView.getSettings().setJavaScriptEnabled(true);
 mWebView.loadUrl("file:///android_asset/dog.html");
 mWebView.setWebChromeClient(new WebChromeClient());
 mWebView.loadUrl("javascript:sayhello('how are you')");
 mWebView.setWebViewClient(getWebViewClient());
    <head>
    <script type="text/javascript" src="somelibrary.js"></script>
    </head>
<body>
<script>
function sayhello(text){
somelibrary.somefunc(text);
}
</script>
</body>
 private WebViewClient getWebViewClient() {
return new WebViewClient() {
            @Nullable
            @Override
            public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) {}
}}