我搜索了很多找到一个解决方案PDF文件,但仍无法找到任何Android的 - 无活动处理意向{行动= android.intent.action.VIEW - 试图打开
我想在我的Android应用程序
这里打开一个PDF文件是我的代码做到这一点:
try
{
File file = new File(Environment.getExternalStorageDirectory()+"/pdf/Read.pdf");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
Log.d("CheckingURI", uri.toString());
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
catch (Exception e)
{
Log.d("OpenPDFError", e.getMessage());
}
Tomcat的日志意味着没有任何活动,以处理这个意图
09-19 19:55:02.938: D/CheckingURI(30483): file:///mnt/sdcard/pdf/Read.pdf
09-19 19:55:02.948: D/OpenPDFError(30483): No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/pdf/Read.pdf typ=application/pdf }
是否有任何其他方式来做到这一点,或者我可以打开PDF文件与另一个默认的PDF查看器?如果是,如何?
更新: 的主要问题是,我没有在我的仿真器上安装一个PDF阅读器应用程序...
再次出现此错误:未找到处理Intent的活动{act = android.intent.action.VIEW dat = file:///mnt/sdcard/pdf/Read.pdf typ = application/pdf flg = 0x40000000} – 2014-09-20 14:37:47
@RasoolGhana:也许你的设备或模拟器上没有安装PDF阅读器。尝试安装PDF查看器并重试。 – ChuongPham 2014-09-20 15:11:49
谢谢,一直在寻找这个。 +1有关“未找到活动...”错误的说明。 – 2014-09-20 16:43:17