android - 如何打开带有特定相册或文件夹的默认图库应用程序?

标签 android android-intent gallery android-gallery

我在网上找到的每个示例都是打开图库并从图库中获取图像作为结果。我的需要是我不想要我的应用程序的结果或图像。我只想通过显示特定的图像文件夹来触发图库应用程序。我的应用程序有单独的文件夹来保存图像。我需要将用户直接导航到该路径。

最佳答案

试试这段代码。它将在 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/

相关文章:

android - 我可以在 firebase 分析中为每个用户设置唯一的用户属性吗?

android - 如何指定 AudioRecorder 对象的输入源?

android - 如果 ID 匹配或文件名匹配,搜索并单击按钮

java - 如何解决imageadpter错误?

android - 带 View 的 Coverflow

java - 在 Android M 中获取经纬度 0.0

android - 调整 androidx.preference 对话框以跟随 Material You

android - 在没有完成()的情况下重新加载 Android 中的 Activity

android - 区别以及何时使用 getApplication()、getApplicationContext()、getBaseContext() 和 someClass.this

html - CSS 画廊 IE 问题