简体   繁体   English

如何仅通过应用程序打开文件

[英]how open a file exclusively with an app

i want open a file with hp ePrint exclusively...but with my code, file is opened with adobe reader...i don't know why.... THANKS IN ADVANCE! 我只想使用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 intent=new Intent();
intent.setPackage("com.hp.android.print")

intent = new Intent(Intent.ACTION_VIEW); intent =新的Intent(Intent.ACTION_VIEW);

intent.setDataAndType(targetUri, "application/pdf");

You redeclared the intent object. 您重新声明了意图对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Adobe Reader专门打开文件PDF? - How open file PDF exclusively with Adobe reader? 如何在外部应用程序 android 中打开存储在应用程序特定存储中的文件? - How open file stored in app specific storage in external app android? 在文件资源管理器中单击其相关文件时如何打开应用程序? - How to open an app when its related file is clicked in file explorer? 如何独家发送到开始的骆驼路线? - How to I exclusively send to started Camel routes? 如何通过应用内浏览器打开PDF文件? - How to open a PDF file from in-app browser? 如何使用 Android 应用程序打开 PDF 文件? - How do I open a PDF file with an Android app? 如何在API 24及更高版本中的另一个应用程序中打开文件-Andorid - How to open a file in another app in API 24 and above - andorid 如何使用 Java 在 default.xslx 应用程序中打开 Excel 文件? - How to open an Excel file in default .xslx app using Java? Android Java:如何在另一个应用程序中使用FileProvider打开下载的文件 - Android Java : How to open a downloaded file using FileProvider in another App Android-如何在不知道我应用程序文件类型的情况下使用默认查看器打开文件 - Android - How to open a file with default viewer without knowing file type from my app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM