the describe: http://www.rqgg.net/topic/vrvkz-select-multiple-images-from-android-gallery.html
If the caller can handle multiple returned items (the user performing multiple selection), then it can specify EXTRA_ALLOW_MULTIPLE to indicate this.
This is pretty interesting. Here they are referring it to the use case where a user can select multiple items?
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void selectPhotos(){
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 multiple images"), SELECT_PHOTOS_RESULT);
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case SELECT_PHOTOS_RESULT:
//how to get the Uris?
...
break;
}
}
To grab several at once, you can enter selection mode by long-pressing on one photo, and then tapping on other pictures or on a date. Doing the latter will automatically select all the images taken on a specific day.
For selecting multiple images in the gallery with Android Jetpack Compose. And then use launcherMultipleImages. launch("image/*") to start the images selection.
To select multiple files press on as many files as you want to select and check marks will appear over all of the selected files. OR you press the More options menu icon in the upper right corner of the screen and press Select.
Probably, i am little late to answer this. Might help someone who is looking for an answer to this.
if (intent != null) {
ClipData clipData = intent.getClipData();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri();
//In case you need image's absolute path
String path= getRealPathFromURI(getActivity(), uri)
}
}
}
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null,
null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
Note: getClipData()
Call requires min API level 16
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With