简体   繁体   English

通过 Android Intent 打开存储在内部存储中的 pdf

[英]Open a pdf stored in internal storage through an Android Intent

I am trying to open a pdf I created in internal storage in a directory.我正在尝试打开我在目录中的内部存储中创建的 pdf。

I even checked in debugger the open pdf code and the Uri and everything is correct but the StartActivity(Intent) fails.我什至在调试器中检查了打开的 pdf 代码和 Uri,一切都正确,但 StartActivity(Intent) 失败。 Please could someone guide me what maybe the issue?请有人指导我可能是什么问题?

lvListorder.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            File file = new File("/storage/emulated/0/Invoice_RestoManager/Order-20190726_014706.pdf");
            Uri uri = Uri.fromFile(file);
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setDataAndType(uri, "application/pdf");
            startActivity(intent1);
           }
    });

I expect the pdfviewer app to open the pdf when this intent gets executed.我希望 pdfviewer 应用程序在执行此意图时打开 pdf。 Right now the app crashes.现在应用程序崩溃了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM