【发布时间】:2015-05-12 18:26:11
【问题描述】:
我只想从存储中选择 pdf、xlsx 和 txt 文件,但 intent.setType 只能执行一个文件(例如,仅 .txt 文件(或)仅 pdf 文件)。是否可以通过编码intent.setType()来获取所有三个文件,有没有办法?
这是我的一些代码。
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(
Intent.createChooser(intent, "Select txt file"),
0);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
}
}
【问题讨论】: