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

时间:2017-07-01 08:13:27

标签: android android-intent gallery android-gallery

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

2 个答案:

答案 0 :(得分:5)

试试这段代码。它将检索storage/emulated/0/Pictures/AppPics下的查看图片。您可以根据目录路径更改文件路径。

File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(sdDir, "AppPics");

if (file.isDirectory()) 
    listFile = file.listFiles();

编辑:使用意图打开文件夹

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);

答案 1 :(得分:0)

你可以这样试试,

f=1
相关问题