问题
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.
回答1:
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();
EDIT: To open your folder using 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);
回答2:
You can try like this,
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = [Uri for your folder];
intent.setDataAndType(uri, "image/*");
startActivity(Intent.createChooser(intent, "Open [App] images"));
来源:https://stackoverflow.com/questions/44858799/how-to-open-default-gallery-app-with-particular-album-or-folder