Iam使用adobe pdf阅读器使用一种方法打开存储在我的SD卡中的PDF文件在Android应用程序中的方法。我正在使用的代码如下所示。使用Abobe pdf阅读器不能显示pdf在Android中
File file=new File(Environment.getExternalStorageDirectory().getAbsoluteFile()+"/Report.pdf");
Uri path=Uri.fromFile(file);
//openFile(file, "application/pdf");
viewPdf(path);
private void viewPdf(Uri file){
Intent intent;
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(file, "application/pdf");
try{
startActivity(intent);
}catch(ActivityNotFoundException e){
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
builder.setTitle("No Application Found");
builder.setMessage("Download from Android Market?");
builder.setPositiveButton("Yes, Please", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
marketIntent.setData(Uri.parse("market://details?id=com.adobe.reader"));
startActivity(marketIntent);
}
});
builder.setNegativeButton("No, Thanks", null);
builder.create().show();
}
}
并且在烤面包中显示以下例外:无法显示pdf(xyz.pdf无法打开)。
请帮我一把。
有任何PDF阅读器应用程序在安装到您的设备或模拟器上? – 2015-03-19 05:24:24
尝试在意图中设置包:intent.setPackage(“com.adobe.reader”); – 2015-03-19 05:25:37
@HareshChhelana是有两个安装的一个是土坯其他是极地办公室5 ...是的,我用com.adobe.reader仍然是异常。如果你有一个工作的例子,请发布它。 – user3469177 2015-03-19 05:33:49