【发布时间】:2011-09-23 09:19:39
【问题描述】:
我将在我的应用程序中显示一个 pdf,并且该 pdf 必须与应用程序捆绑在一起。
有什么好的方法可以做到这一点?
我已经读到可以通过将 pdf 文件添加到 res/raw 文件夹并从那里读取它来做到这一点,但是当我将 pdf 文件放在那里时会出现项目错误。
所以我尝试将pdf文件放在项目的asset文件夹中,它没有报错。
这就是我尝试显示 pdf 的方式:
File pdfFile = new File("res/raw/file.pdf");
Uri path = Uri.fromFile(pdfFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
有什么想法或建议吗?
提前致谢
【问题讨论】: