【问题标题】:How to prevent "complete action using" while opening pdf file using Adobe Reader.使用 Adob​​e Reader 打开 pdf 文件时如何防止“使用完成操作”。
【发布时间】:2012-07-18 07:17:41
【问题描述】:

我想使用已安装的 adobe 阅读器打开 pdf 文件。我尝试通过以下方式阻止“使用完成操作”菜单。

Intent intent = new Intent();
intent.setPackage("com.adobe.reader");
intent.setDataAndType(Uri.fromFile(doc), "application/pdf");
startActivity(intent);

使用上面的代码,我设法将列表大小减少到 2。有没有办法避免显示上下文菜单(使用完成操作)。

谢谢!

【问题讨论】:

    标签: android pdf adobe


    【解决方案1】:

    当两个activity具有相同的intent filter action时,Android系统会自动显示“complete action using”对话框。一旦您选择了默认操作。 Android 不会显示它并使用默认操作完成任务。

    【讨论】:

    • 谢谢 sunil,有什么办法可以通过编程方式选择默认操作
    • 请不要在您的回答中宣传您的博客。 Bo 已编辑掉您使用的页脚,如果您不再这样做,我们将不胜感激。
    【解决方案2】:

    我要感谢每一位试图回答这个问题的人。经过一番浏览,我找到了我的问题的解决方案。这对我来说非常有用。

    而不是使用

    intent.setPackage("com.adobe.reader");
    

    我用过

    intent.setClassName("com.adobe.reader", "com.adobe.reader.AdobeReader");
    

    不要忘记在 try catch 块中启动活动,当设备上未安装 adobe reader 时它会有所帮助。请检查下面的sn-p。

    try {
        Intent intent = new Intent();
    
        intent.setClassName("com.adobe.reader", "com.adobe.reader.AdobeReader");
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(doc), "application/pdf");
        startActivity(intent);
    
       } 
       catch (ActivityNotFoundException activityNotFoundException) {
        activityNotFoundException.printStackTrace();
        }
    

    【讨论】:

      猜你喜欢
      • 2014-03-10
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-09
      • 1970-01-01
      • 2019-06-21
      • 2019-02-16
      相关资源
      最近更新 更多