简体   繁体   English

使用 Intent.ACTION_OPEN_DOCUMENT 从特定文件夹打开文件

[英]Open file from specific folder with Intent.ACTION_OPEN_DOCUMENT

I would like to open the file picker at a specific path.我想在特定路径打开文件选择器。 The user should be able to pick any file on the phone, but the SAF should show a specific folder first.用户应该能够选择手机上的任何文件,但 SAF 应该首先显示特定文件夹。 I tried the following but it always opens the downloads folder.我尝试了以下操作,但它总是打开下载文件夹。 Thanks!谢谢!

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 
intent.addCategory(Intent.CATEGORY_OPENABLE);
Uri uri = Uri.parse(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath());
intent.setDataAndType(uri,"image/*");

startActivityForResult(intent, 1);

you need to use the extra EXTRA_INITIAL_URI您需要使用额外的EXTRA_INITIAL_URI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取使用 Intent.ACTION_OPEN_DOCUMENT 选择的文件的文件扩展名? - How to get file extension of a file picked with Intent.ACTION_OPEN_DOCUMENT? 如何在 Android Pie 中使用 Intent.ACTION_OPEN_DOCUMENT - How to use Intent.ACTION_OPEN_DOCUMENT in Android Pie 使用Release APK中的Intent.ACTION_OPEN_DOCUMENT读取大文本文件时,IOException EBADF(错误文件描述符) - IOException EBADF (Bad file descriptor) when reading large text files using Intent.ACTION_OPEN_DOCUMENT in Release APK 使用Intent.ACTION_OPEN_DOCUMENT_TREE将文件写入目录 - Write file to directory using Intent.ACTION_OPEN_DOCUMENT_TREE 在 Android Java 上打开特定文件夹 - Open specific folder with intent on Android Java 当我启动意图ACTION_OPEN_DOCUMENT_TREE时,它会自动打开一个空的最近文件夹吗? - When i start the intent ACTION_OPEN_DOCUMENT_TREE it automatically opens empty recent folder? 尝试有意打开文件夹 - trying open folder with intent 如何为 ACTION_OPEN_DOCUMENT 意图实现自定义 MIME 类型? - How to implement a custom MIME type for ACTION_OPEN_DOCUMENT intent? 在 Intent.ACTION_OPEN_DOCUMENT_TREE 返回的目录中创建新文件 - Create new file in the directory returned by Intent.ACTION_OPEN_DOCUMENT_TREE 如何通过 ACTION_OPEN_DOCUMENT_TREE 在下载文件夹中创建文件夹 - how to make folder in Download folder by ACTION_OPEN_DOCUMENT_TREE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM