【发布时间】:2014-06-18 14:40:55
【问题描述】:
我正在尝试使用此代码在外部 pdf 查看器中查看本地 pdf:
Uri path = Uri.parse("android.resource://<package-name>/raw/Terms.pdf>");
try
{
Intent intentUrl = new Intent(Intent.ACTION_VIEW);
intentUrl.setDataAndType(path, "application/pdf");
intentUrl.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intentUrl);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(getActivity(), "No PDF Viewer Installed", Toast.LENGTH_LONG).show();
}
即使我安装了 Adobe PDF,它也会引发 ActivityNotFoundExcecption。
这是为什么呢?
【问题讨论】:
-
重复stackoverflow.com/questions/13517412/… 和无数其他问题
-
@CommonsWare ...这些都不适合我,所以我想我会再次问这个问题:)
标签: android pdf activitynotfoundexception