gpt4 book ai didi

android - 阅读放置在android Assets 文件夹中的pdf文件

转载 作者:行者123 更新时间:2023-11-30 04:21:29 29 4
gpt4 key购买 nike

我的 Assets 文件夹中有一个 pdf 文件,我正在激发阅读它的 Intent 。这是我的代码:

 Uri path = Uri.parse("file:///android:asset/about.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

当我这样做时,会出现一个弹出窗口,其中包含应用程序列表,包括 adobe reader但是当我点击它时,会出现一个对话框说:“错误”,文件路径无效

请告诉我如何解决这个问题

最佳答案

此文件是否在您应用的 Assets 文件夹中?如果是,那么你的 URI 是错误的,查看这个问题:

How to open a pdf stored either in res/raw or assets folder?

有一个答案描述了如何为您的 Assets 构建正确的 URI。

关于android - 阅读放置在android Assets 文件夹中的pdf文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9207203/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com