30

@See this https://stackoverflow.com/a/15029515/185022

I`m trying to select images from gallery, but i only found the way to select a single image.

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

Is there a way to select multiple images?

Community
  • 1
  • 1
spe
  • 1,031
  • 6
  • 18
  • 24

4 Answers4

7

Create a custom gallery same like: Android custom image gallery with checkbox in grid to select multiple

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
Siklab.ph
  • 991
  • 11
  • 17
6

First of all you need to use putExtra with your photoPickerIntent

photoPickerIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE);

Then in your on activity result you should get ClipData from Intent like this

ClipData clipData = data.getClipData();
//Where data is param intent of onActivityForResult

And iterate this clipData to get URI for specific picked image.

for (int i = 0; i < clipData.getItemCount(); i++){
    Uri uri = clipData.getItemAt(i).getUri();
}

I hope this helps

lukaspp
  • 1,059
  • 10
  • 15
1

I think, you should implement custom gallery for multiple image pick action.

see here in details.

Community
  • 1
  • 1
Bhavesh Hirpara
  • 22,255
  • 15
  • 63
  • 104
1

Why don't you try ACTION_SEND_MULTIPLE thing. You will receive a set of Uris.

Something like

    if (Intent.ACTION_SEND_MULTIPLE.equals(action))
        && Intent.hasExtra(Intent.EXTRA_STREAM)) {
        ArrayList<Parcelable> list =
    intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        for (Parcelable parcel : list) {
           Uri uri = (Uri) parcel;
           /// do things here.
       }
    } 

Saw this code block on a google-groups post. Just try this out. Thanks.

VenoM
  • 364
  • 3
  • 10
  • 1
    @kalpesh Ok, It's like you fire your activity with **Intent.ACTION_SEND_MULTIPLE**, and should override your **onActivityResult()**, inside which u write the above _code_. I haven't tried out this code yet, as I'm in the middle of something. The above code just verifies, if the action is what u fired and it has extra data, then collect the results to an array list. For further details, see [this](http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE). Hope this helps. :) – VenoM Dec 19 '11 at 06:24
  • I mean willtate's answer is more than enough. – VenoM Dec 19 '11 at 06:27
  • First thanks for reply. But M sorry I try your code as said by you but this Intent is called to send activity from my device. I am new in android developer So is their possibility of my mistake. At Now i follow the answer of willtake..... – Kalpesh Dec 20 '11 at 06:45
  • 1
    Sorry my mistake, Send won't let you pick. Forget this. – VenoM Dec 21 '11 at 11:04
  • It's ok....I think likeaboss answer is also very useful....I think in android all thing is going better when we use it as custom......what's you say...? – Kalpesh Dec 22 '11 at 05:35
  • This is the code needed to receive multiple files from the gallery ACTION_SEND_MULTIPLE intent, it helped me. – accordionfolder Sep 17 '12 at 16:04