相关疑难解决方法(0)

如何为pdf,xlsx和txt文件android制作intent.setType?

我想从存储中仅选择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)

android android-intent

30
推荐指数
6
解决办法
4万
查看次数

标签 统计

android ×1

android-intent ×1