Search code examples
androidgalleryandroid-gallery

Android Gallery - Multiple Images - Pre-selected images


I need to allow a person to upload multiple images in my app. So I open the gallery like so -

  Intent intent = new Intent();
         intent.setType("image/*");
         intent.setAction(Intent.ACTION_GET_CONTENT);
         intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
         startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_GALLERYPICK);

And handle the URIs returned like this -

 if (data.getClipData() != null) {
                    ClipData mClipData = data.getClipData();
                    mArrayUri = new ArrayList<Uri>();
                    for (int i = 0; i < mClipData.getItemCount(); i++) {

                        ClipData.Item item = mClipData.getItemAt(i);
                        Uri uri = item.getUri();
                        mArrayUri.add(uri);
                    }
                }

So I have a list of URIs that the user had selected and I can display bitmap-thumbnails of the same in the activity.

The problem is, I have an "Add More Photos" button which should open the gallery again but the photos he selected last time should already be ticked.

How do I implement this pre-selection?


Solution

  • This is not possible with ACTION_GET_CONTENT. There is no means to tell an arbitrary third-party app "please pre-select these images".