无论如何要显示大的pdf文件

时间:2018-03-10 09:47:45

标签: android pdf-viewer

您好我使用以下代码显示来自网址的pdf文件。但它给出了一个错误“哎呀这个文件太大而无法预览”而且我的pdf文件没有打开。有没有办法逃避这个错误非常感谢:

 super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_giris);
  /*  webview = (WebView)findViewById(R.id.webview);
    progressbar = (ProgressBar) findViewById(R.id.progressbar);
    webview.getSettings().setJavaScriptEnabled(true);
 String filename ="https://xxxxx.files.wordpress.com/2014/01/xxxx-pdf.pdf";
    webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filename);

    webview.setWebViewClient(new WebViewClient() {

        public void onPageFinished(WebView view, String url) {
            // do your stuff here
            progressbar.setVisibility(View.GONE);
        }
    });*/
    File file = new File(Environment.getExternalStorageDirectory(), "Report.pdf");
    Uri path = Uri.fromFile(file);
    Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW);
    pdfOpenintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    pdfOpenintent.setDataAndType(path, "https://xxxx.files.wordpress.com/2014/01/xxxx-pdf.pdf");
    try {
        startActivity(pdfOpenintent);
    } catch (ActivityNotFoundException e) {

    }}}

0 个答案:

没有答案