Mozilla的pdf.js的WebView要求互联网 [英] mozilla pdf.js webview ask for internet

查看:314
本文介绍了Mozilla的pdf.js的WebView要求互联网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Mozilla / pdf.js显示在网页视图在我的Andr​​oid应用程序的PDF文件。该框架不需要任何互联网连接来渲染PDF格式。如果下载了js文件和一切,因此可以使用它。尽管如此,每次我想开一个新的PDF打开的Andr​​oid与无线设置对话框中的默认浏览器。

I'm using mozilla/pdf.js to display a pdf in a webview in my Android application. The framework doesn't need any internet connection to render the pdf. If downloaded the .js file and everything so it can use that. Still every time I want to open a new pdf Android opens the default browser with the wireless settings dialog.

关闭应用程序,并再次打开它后的PDF渲染。我的Internet连接两个无线数据被禁止,所以它不需要互联网的东西,我相信这一点。

After closing the app and opening it again the PDF is rendered. My internet connection both wireless as data is disabled, so it doesn't need anything of internet, I'm sure about that.

我怎样才能解决这个问题,该web视图要求互联网?

How can I solve this that the webview ask for internet?

这是我的code:

    webView = (WebView) findViewById(R.id.webViewWindow);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setBuiltInZoomControls(true);
    webView.setWebChromeClient(new WebChromeClient());
    webView.loadUrl("file:///android_asset/pdfviewer/index.html");

我也是Android开发页面,该setAllowFileAccessFromFileURL和setAllowUniversalAccessfromFileURLS都没有必要上找到。你应该只使用通用的,这是真的还是我理解这个正确?

I also found on the Android dev page that the setAllowFileAccessFromFileURL and the setAllowUniversalAccessfromFileURLS are both not necessary. You should use only the universal one, is this true or do I understand this incorrectly?

推荐答案

我被解决了这个问题:

webView.setWebViewClient(new WebViewClient() {
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
        Log.d("Debug","Error");
    }
});

然后你有关于误差控制,你可以像我一样选择做什么。

Then you have control about the error and you can like me choose to do nothing.

这篇关于Mozilla的pdf.js的WebView要求互联网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆