我想从存储中仅选择pdf,xlsx和txt文件,但intent.setType只能执行一个文件(仅限eg.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
}
}
Run Code Online (Sandbox Code Playgroud)