更新时间:2023-09-28 09:32:28
您将能够从显示它生/
或资产/
如果您的应用程序实际上实现了一个PDF阅读器。既然你想让它显示在一个单独的应用程序(如Adobe Reader的),我建议做如下:
You would be able to show it from raw/
or assets/
if your application actually implemented a PDF reader. Since you want it to be displayed in a separate application (such as Adobe Reader), I suggest doing the following:
资产/
目录中的PDF文件。意图
就像你现在正在做,除非使用getAbsolutePath()$c$c>上为意图的数据新创建的文件。assets/
directory.openFileOutput
or getExternalFilesDir
.Intent
just like you are doing now, except use getAbsolutePath()
on the newly created file for the intent's data.请注意,用户可能没有一个PDF阅读应用程序。在这种情况下,捕捉是有用的ActivityNotFoundException$c$c>并显示相应的消息。
Be aware that a user might not have a PDF reading application. In this case, it is useful to catch the ActivityNotFoundException
and show an appropriate message.