Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.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
自定义shouldInterceptRequest()不在android的webview上加载javascript(jelly bean)_Java_Android_Webview_Webviewclient - Fatal编程技术网

自定义shouldInterceptRequest()不在android的webview上加载javascript(jelly bean)

自定义shouldInterceptRequest()不在android的webview上加载javascript(jelly bean),java,android,webview,webviewclient,Java,Android,Webview,Webviewclient,我只对Android果冻豆(4.1、4.2、4.3)使用以下代码 我在webViewclient public WebResourceResponse shouldInterceptRequest(WebView view, String sourceurl) { try { URL url = new URL(sourceurl); HttpsURLConnection urlConnection = (HttpsURLConnection)

我只对Android果冻豆(4.1、4.2、4.3)使用以下代码 我在
webViewclient

public WebResourceResponse shouldInterceptRequest(WebView view, String sourceurl) {
     try {

         URL url = new URL(sourceurl);

         HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();

         //make https connection using tls
         SSLContext sslcontext = SSLContext.getInstance("TLS");
         sslcontext.init(null, null, null);
         SSLSocketFactory noSSLv3Factory = null;

         noSSLv3Factory = new TLSSocketFactory();
         urlConnection.setSSLSocketFactory(noSSLv3Factory);

         String responseEncoding = urlConnection.getContentEncoding();
         String responseMimeType = urlConnection.getContentType();
         return new WebResourceResponse(responseMimeType, responseEncoding, urlConnection.getInputStream());

    } catch (Exception e) {
          e.printStackTrace();
    }

    return null;
}
我使用类创建启用TLS的套接字到HttpsURLConnection请求。它很好用

现在webview显示我的网站,但它不会加载网站中的任何js文件。我的网页中没有发生太多事件。然后,当我运行我的应用程序时,会出现以下错误:

E/Web Console: Uncaught SyntaxError: Unexpected token ILLEGAL at https://www.google-analytics.com/analytics.js:1

E/Web Console: Uncaught SyntaxError: Unexpected token ILLEGAL at https://mytestsite.com/wp-includes/js/jquery/jquery.js?ver=1.12.4:1

并非所有java脚本文件都加载了相同的错误消息。

您是否能够解决问题?