【发布时间】:2021-12-03 03:56:28
【问题描述】:
我想用 Intent 打开一个特定的文件夹,但它只打开最近的文件,如下所示:
我的代码(更新):
//path i want to open: /storage/emulated/0/Android/data/org.pytorch.demo.objectdetection/files/Pictures/saved_images
String myDir = Environment.getExternalStorageDirectory() + "/" + "Android/data/org.pytorch.demo.objectdetection/files/Pictures/saved_images" + "/";
Uri uri = Uri.parse(myDir);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "*/*");
startActivity(intent);
【问题讨论】:
-
抱歉,Android 不支持“打开特定文件夹”。此外,
file/*不是有效的 MIME 类型,myDir不是要解析的Uri的有效字符串表示形式。 -
好的!我已经更改了“/”的类型并从 myDir 创建了一个 Uri。但它不断打开最近的文件(代码更新到现在的样子)
-
抱歉,Android 不支持“打开特定文件夹”。
-
Open specific folder with intent on Android Java标题错误。您的意思是:使用 ACTION_VIEW。但 ACTION_VIEW 不用于文件夹开头。
标签: java android android-intent