【问题标题】:how to select pdf file using intent and get that selected pdf file path in onActivityResult如何使用意图选择pdf文件并在onActivityResult中获取选定的pdf文件路径
【发布时间】:2017-02-27 06:52:30
【问题描述】:
  • 我正在尝试使用 Intent 选择 pdf 并获取所选的 pdf 文件路径,但我不确定它的对错。
  • 如果没有,我如何在onActivityResult 中获取 pdf 路径。

Intent intent = new Intent();
intent.setType("pdf/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);

【问题讨论】:

  • link 这样对吗??
  • 首先将类型改为"applicaiton/pdf"

标签: android pdf android-intent mime-types


【解决方案1】:

使用 application/pdf 行我可以做到这一点。

Intent intent = new Intent();
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-10
    • 2021-03-25
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 2010-12-24
    • 2012-04-06
    • 1970-01-01
    相关资源
    最近更新 更多