我在android phonegap中非常新。我想从我的SD卡打开pdf文件。 我正在使用此链接
http://www.giovesoft.com/2011/08/download-and-open-pdf-with-phonegap.html
这里,pdf文件存储在sdcard中,而我尝试打开该文件意味着它在我的logcat中显示以下错误消息
PdfViewer:加载网址时出错
/sdcard/Downloads/:android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE]
dat=file:///sdcard/Downloads typ=application/pdf flg=0x4000000 }
任何人都可以帮助我?
答案 0 :(得分:0)
现在上面的问题已经解决,这里是我的代码:
public String showPdf(String fileName) {
File file = new File(fileName);
Log.d("PdfViewer", "list: " + file.exists());
if (file.exists()) {
try {
Intent intent = new Intent();
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
this.ctx.startActivity(intent);
Log.d("PdfViewerr", "read: " + fileName);
return "";
} catch (android.content.ActivityNotFoundException e) {
System.out.println("PdfViewer: Error loding url "+fileName+":"+ e.toString());
Log.d("PdfViewer", "error: " + fileName);
return e.toString();
}
}else{
Log.d("PdfViewer", "notfound: " + fileName);
return "file not found";
}
}