如何打开具有特定专辑或文件夹的默认图库应用程序? [英] How to open default gallery app with particular album or folder?

查看:88
本文介绍了如何打开具有特定专辑或文件夹的默认图库应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Every example i found on net is opening gallery and get images from gallery as result. My need is i don't want result or images to my app. I just want to trigger gallery app with showing particular folder of images. My App Have separate folder to save images. i need to navigate users directly to that path.

推荐答案

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

Try this code. It will retrieve view pictures under storage/emulated/0/Pictures/AppPics You can change the file path according to your directory path.

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

这篇关于如何打开具有特定专辑或文件夹的默认图库应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆