android - 从存储中选择 pdf 文件

标签 android android-intent

我想打开手机存储 emulated/storage/0/ 并只过滤 pdf 文件,以便用户可以选择。
我尝试了这段代码,但在 fileChoser 中,我只能使用 DropBoxGoogleDrive 等第三方应用程序打开它。我如何使用 android Explorer 打开它?

addPDF.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

              Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("application/pdf");
            startActivityForResult(intent,PICK_PDF_REQUEST);
            }
        });

编辑:我在 4.2 和 6.0 上都试过了,我在 filechooser 中唯一的选择仍然是 DriveDropbox

最佳答案

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
startActivityForResult(intent, SAVE_REQUEST_CODE);

关于android - 从存储中选择 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50397948/

相关文章:

android - 分页库过滤器/搜索

android - 选择出生日期对话框

java - 如何将 TextView 设置为长值?

android - 多次调用 Application.onCreate

android - 从一个 ListView Activity 移动到另一个 ListView Activity

android - android中不调用隐式 Intent

java - Android Studio - 无法从预装的 sqlite 数据库检索数据

Android NFC Activity 正在重新启动,即使它位于堆栈的顶部

java - AndroidTestCase 中永远不会调用 AsyncTask 的 onPostExecute()

java - 通过广播接收器检测浏览器启动