简体   繁体   English

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

[英]Open a specific folder (not a image) in Gallery in Android Studio

I write this code which open gallery with all folder:我写了这段代码,用所有文件夹打开画廊:

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

But I want to open an specific folder with built-in Gallery.但我想打开一个带有内置图库的特定文件夹。 I search about this and I found some people posted about this problem in stack overflow but there was no perfect sollution in any post.我搜索了这个,我发现有些人在堆栈溢出中发布了关于这个问题的帖子,但在任何帖子中都没有完美的解决方案。 Can anyone help me?谁能帮我?

The location of photos is always the same - it's the DCIM/Camera folder.照片的位置总是相同的——它是 DCIM/Camera 文件夹。 The full path looks like this:完整路径如下所示:

  • /storage/emmc/DCIM - if the images are on the phone memory. /storage/emmc/DCIM - 如果图像在手机内存中。
  • /storage/sdcard0/DCIM - if they are on memory card. /storage/sdcard0/DCIM - 如果它们在存储卡上。

OR by code.或通过代码。

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

and to open these specific folders you can [follow this answer.][1] https://stackoverflow.com/a/10749615/1371792 并打开这些特定的文件夹,你可以[按照这个答案。][1] https://stackoverflow.com/a/10749615/1371792

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM