I want to open gallery with multiple image selection functionality and i am using following code.
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);
It opens gallery app but doesn't let me choose multiple images.
This worked for me from api22 to api29.
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 105);
then in activity result overmethod add this code.
if (resultCode == RESULT_OK && requestCode == 105) {
ClipData clipData = data.getClipData();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); i++) {
Uri imageUri = clipData.getItemAt(i).getUri();
// your code for multiple image selection
}
} else {
Uri uri = data.getData();
// your codefor single image selection
}
Note: after you got the gallery screen hold the image little longer. then in top right click "open". it will allow you to select multiple images.