【发布时间】:2015-11-20 20:01:49
【问题描述】:
我正在使用以下代码使用Intent 选择 PDF 文件。它在 Android 5.0+ 上完美运行,但 API 18 上没有合适的应用程序打开 PDF 文件消息。
public static Intent pickPdf() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
intent.addCategory(Intent.CATEGORY_DEFAULT);
return intent;
}
startActivityForResult(Intent.createChooser(pickPdf(), "Open with"), PICK_PDF);
【问题讨论】:
-
Android 中没有内置任何东西必须处理该 MIME 类型的
Intent操作。 -
@CommonsWare 如果你想从存储中选择一个使用
Intent的PDF文件,你会怎么做? -
回退显示您自己选择的 UI(使用
MediaStore查找所有application/pdf文件,显示在ListView或RecyclerView中)。
标签: android pdf android-intent