我将在我的应用程序中显示pdf,并且pdf必须与应用程序捆绑在一起.
有什么好办法呢?
我已经读过,可以通过将pdf文件添加到res/raw文件夹并从那里读取它来实现这一点,但是当我将pdf文件放在那里时我得到了项目错误.
所以我试着把pdf文件放在项目的资产文件夹中,它没有给出任何错误.
这是我试图显示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);
Run Code Online (Sandbox Code Playgroud)
任何想法或建议?
提前致谢