在Android Studio的Gallery中打开特定文件夹(而不是图像)



我写了这段代码,用所有文件夹打开图库:

{
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

但我想打开一个内置Gallery的特定文件夹。我搜索了一下,发现一些人发布了关于堆栈溢出问题的帖子,但在任何帖子中都没有完美的解决方案。有人能帮我吗?

照片的位置总是相同的-它是DCIM/Camer文件夹。完整路径如下所示:

  • /storage/emmc/DSIM-如果图像在手机内存中
  • /storage/sdcard0/DCIM—如果它们在存储卡上

按代码进行OR运算。

private static String getGalleryPath() {
return photoDir = Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DCIM + "/";   
}

要打开这些特定的文件夹,您可以[按照这个答案操作][1]https://stackoverflow.com/a/10749615/1371792

最新更新