Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select multiple images from Photo Gallery on Android using Intents

@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?

like image 880
spe Avatar asked Jan 20 '11 11:01

spe


People also ask

How do you select multiple images?

For selecting multiple images in the gallery with Android Jetpack Compose. And then use launcherMultipleImages. launch("image/*") to start the images selection.


2 Answers

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

like image 50
Siklab.ph Avatar answered Sep 28 '22 01:09

Siklab.ph


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

like image 42
lukaspp Avatar answered Sep 28 '22 01:09

lukaspp