Android ACTION_VIEW Multiple Images
I have one to three photos that I would like to display in my application. I won't know until they show you how many photos have been downloaded from the Internet.
I cannot figure out how to create an intent for displaying photos. Right now I am caching them on the SD card under the folder I created by doing something like (no error checking):
final File externalDirectory = Environment.getExternalStorageDirectory();
final String folder = externalDirectory.getAbsolutePath() + "/Android/data/" + packageName + "/files/";
This was explained in the Android Developer's Reference .
I can display one photo by following these steps:
final Uri uri = Uri.fromFile(file);
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
Util.startActivity(this, intent);
Where file
is the file of the saved photo.
If that helps, I can save the images anywhere my application can access, however I would prefer that the photos not appear in the list with the user's other personal photos as this can be annoying.
The image viewer has a "Slideshow" menu item, so it needs to be aware of a few photos.
I could create my own Image Viewer, but this seems like additional work and beyond what I would reasonably expect. Even if I did, I would like the user to be able to install a third-party Image Viewer and have a better experience with panning, zooming, sharing, ...
I tried to use the cached photo files directory to create the Uri, but the Image Viewer shows a black page. If I go to a file it only shows one file and others.
I know this should be possible because I can use the Gallery app and show photos if I manually select a folder. Every time I research this issue, the comments say that it is not possible to show multiple images.
I suspect there is a magic spell, but what?
source to share
I think that your goal is not within your power. If your viewer app is designed to handle multiple images or a catalog, you can ask it to show it however you want, but you're tuned in to the viewer template.
I have a third party QuickPic image viewer installed . I just checked your code snippet and the system exited the select dialog so that I can select the application to show the images in the folder. If I choose my own gallery then I only see an empty folder and Quickpic works the way I want.
PS: I will explain my folder Uri application this way:
intent.setDataAndType(Uri.fromFile(new File("//mnt/sdcard/test/")), MimeTypeMap.getSingleton().getMimeTypeFromExtension("png"));
source to share