【问题标题】:Android: PDF files hidden despite setting the MIME typeAndroid:尽管设置了 MIME 类型,但 PDF 文件仍被隐藏
【发布时间】:2016-08-01 02:36:45
【问题描述】:

这是我的意图:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/* , application/pdf, image/*");

但是,当文件资源管理器出现时,PDF 文件显示为灰色,即无法选择。有什么解决方法吗?

【问题讨论】:

    标签: android pdf android-intent mime-types android-intent-chooser


    【解决方案1】:

    如果您使用的是最低 Android 版本 19,那么您可以通过以下方式执行此操作

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent .setType("*/*");
    String[] mimeTypes = {"image/*", "application/pdf"};
    intent .putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
    

    【讨论】:

      【解决方案2】:

      试试

      intent.setType("text/*|application/pdf|image/*");
      

      【讨论】:

      • 试过了,还是看到PDF文件变灰
      猜你喜欢
      • 2015-07-18
      • 1970-01-01
      • 2015-09-24
      • 2021-04-13
      • 2015-07-18
      • 1970-01-01
      • 2015-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多