【发布时间】:2014-07-11 14:26:29
【问题描述】:
我打算用我设备的默认应用程序打开一个 PDF 文件。我在提供资产文件夹中的地址时遇到问题。
我的给地址代码如下:
File pdfFile = new File("file:///android_assets/test.pdf");
Uri path = Uri.fromFile(pdfFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
当 Adobe Reader 打开时,此代码会给出错误 This path is not valid。正确的地址是什么?
【问题讨论】: