Android webView-无法加载某些链接-无效流收到RST

时间:2019-07-23 14:28:43

标签: android android-webview

我创建了一个简单的webView应用,该应用指向我们的网上商店。

问题:

我们在Download page上提供了一些文件,但是当它与智能手机Chrome浏览器一起使用时,我无法通过该应用下载任何文件。

HTML:

<a class="thirdbox" href="/media/wysiwyg/pdf/systemaufbau-anleitungen.pdf" target="_blank" download="blizz-z_Systemaufbau_Anleitungen" title="Datei downloaden">
<div class="iconlink">
    <p>Systemaufbau Anwendungsbroschüre<br><span style="font-size: 75%;">(PDF 5,8 MB)</span></p>
</div>
</a>

我正在使用此代码,它还修复了tel:mailto:之类的链接无法加载的错误。

但是,如果我单击该页面上的链接,则不会输入功能shouldOverrideUrlLoading。我在log语句中设置了一个断点,但从未触发过该断点。

myWebView.setWebViewClient(new WebViewClient() {

    ...

    // Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
        Log.i("debug_log", "shouldOverrideUrlLoading");

    // Allow download of .pdf files
        if (url.endsWith(".pdf")) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            // if want to download pdf manually create AsyncTask here
            // and download file
            return true;
        }

    // Allow URL's starting with /
        if (url.startsWith("/")) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(website + url)));
            // if want to download pdf manually create AsyncTask here
            // and download file
            return true;
        }

    // Also allow urls not starting with http or https (e.g. tel, mailto, ...)
        if( URLUtil.isNetworkUrl(url) ) {
            return false;
        } else {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        }

        return true;
    }

});

如果我单击文件链接,这将登录到logcat控制台:

  

收到无效流的RST

1 个答案:

答案 0 :(得分:0)

我发现这是因为html Scanner input = new Scanner(System.in); int[] arr = new int[5]; int[] dup = new int[5]; int duplicate; for ( int i = 0 ; i < arr.length; i++ ) { System.out.println ("Enter integer: "); arr[i] = input.nextInt(); if((arr[i] >=10) && (arr[i] <=100)) { System.out.printf("Output: %d\t",arr[i]); for(int j = 0 ; j < arr[i] ; j++) { if(dup[j] == arr[i]) { dup[j] = arr[i]; duplicate = dup[j]; } } } else { System.out.println ("enter number between 10-100"); } } 标签 如果我删除了它,那么它就起作用了,因为Webview不支持它。

download