【问题标题】:open a particular file by default in an already installed 3rd party app?在已安装的第 3 方应用程序中默认打开特定文件?
【发布时间】:2012-09-01 09:04:33
【问题描述】:

默认情况下,是否可以通过从我的 android 应用程序传递意图在启动应用程序时在第 3 方 PDF 阅读器(例如 Adob​​e 阅读器)中打开特定的 PDF 文件?

这可能吗?应该如何传递意图来实现这一点?

【问题讨论】:

    标签: android pdf android-intent launch


    【解决方案1】:

    是的,这是可能的。

    您需要启动Intent 和ACTION_VIEW 以及相应的mime 类型,并且应该在3d 方pdf 阅读器中打开该文档(如果您的手机上有)。

    String path="...../file.pdf";
    Intent intent=new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(path)), "application/pdf");
    startActivity(intent);
    

    【讨论】:

    • 我用它来打开 pdf 并且像一个魅力一样工作但是当我尝试使用这个 'intent.setDataAndType(Uri.fromFile(new File(path)), "application/xls" 打开一个 .xls );'应用程序关闭....我该如何解决这个问题
    • 找到了 :) " intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.ms-excel"); "
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多