我在网上找到的每个示例都是打开图库并从图库中获取图像作为结果。我的需要是我不想要我的应用程序的结果或图像。我只想通过显示特定的图像文件夹来触发图库应用程序。我的应用程序有单独的文件夹来保存图像。我需要将用户直接导航到该路径。
最佳答案
试试这段代码。它将在 storage/emulated/0/Pictures/AppPics
下检索 View 图片。您可以根据您的目录路径更改文件路径。
File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(sdDir, "AppPics");
if (file.isDirectory())
listFile = file.listFiles();
编辑:使用 Intent 打开文件夹
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.withAppendedPath(Uri.fromFile(file), "/AppPics"), "image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
关于android - 如何打开带有特定相册或文件夹的默认图库应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44858799/