【发布时间】:2015-03-23 07:56:50
【问题描述】:
我已在我的应用程序raw/my_pdf.pdf 中放置了一个 pdf 文件,以防止被复制并希望在我的平板电脑中使用外部应用程序打开它
这是我尝试过的:
public void loadDocInReader(View v)
throws ActivityNotFoundException, Exception {
try {
Intent intent = new Intent();
intent.setPackage("com.foobnix.pro.pdf.reader");
intent.setDataAndType(Uri.parse("raw/my_pdf.pdf"), "application/pdf");
startActivity(intent);
} catch (ActivityNotFoundException activityNotFoundException) {
activityNotFoundException.printStackTrace();
throw activityNotFoundException;
} catch (Exception otherException) {
otherException.printStackTrace();
throw otherException;
}
}
此方法启动我想要的外部应用程序,但没有 pdf 文件,只是一个空白页
我也知道可以将其作为输入流:
InputStream raw = getResources().openRawResource(R.raw.my_pdf)
但是如何用我指定的应用打开它
有什么办法可以解决
【问题讨论】:
标签: android pdf inputstream private