我想尝试使用HP ePrint应用程序直接打开PDF文件,但我很少混淆我应该发送到这个包名称的参数(com.hp.android.print),所以我只需点击打印按钮,而不是预览使用Adobe Acrobat,然后我得到我的打印文档的结果(更有效)
这是我的代码,但默认打开的应用程序使用的是Adobe Acrobat
File dir = null; if(filename!= null&&!filename.isEmpty()){ dir = new File(Environment.getExternalStorageDirectory()。toString()+“/ Offer /”+ offerordernum.substring(0,10)+ “/” +文件名); Uri uri = Uri.fromFile(dir);
Boolean isIntentSafe=false;
PackageManager pm = mycontext.getPackageManager();
try {
pm.getPackageInfo("com.adobe.reader",0);
Intent intent = new Intent();
intent.setPackage("com.adobe.reader");
intent.setDataAndType(uri, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mycontext.startActivity(intent);
}catch (PackageManager.NameNotFoundException e) {
final String appPackageName = "com.adobe.reader"; // getPackageName() from Context or Activity object
try {
mycontext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
}catch (android.content.ActivityNotFoundException anfe) {
mycontext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
}else {
}
我已尝试使用更改的packagename,但这是错误运行时间。有人可以帮我解决这个问题吗? 这里是HP ePrint文档在运行print之前的类似屏幕截图