0
我想用hp ePrint專門打開文件...但是用我的代碼,用adobe reader打開文件...我不知道爲什麼...... 感謝提前!如何用應用程序專門打開文件
public void viewPDF() {
String path = "/sdcard/droidText/ciccia.pdf";
try {
File targetFile = new File(path);
Uri targetUri = Uri.fromFile(targetFile);
Intent intent=new Intent();
intent.setPackage("com.hp.android.print");
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(targetUri, "application/pdf");
startActivity(intent);
}catch(ActivityNotFoundException anfe){
final String appPackageName="com.hp.android.print";
try{
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" +appPackageName)));
}catch(android.content.ActivityNotFoundException anfer){
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://play.google.com/store/apps/details?id=" +appPackageName)));
}
}
}
我需要刪除這個intent = new Intent(Intent.ACTION_VIEW);? – cbasso
是的。而不是寫這個'intent.setAction(Intent.ACTION_VIEW);'並嘗試。 – Uday
如果我只刪除這個ntent = new Intent(Intent.ACTION_VIEW)?它是一樣的嗎? – cbasso