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