How to read/retrieve paths or Uri[] when I select multiple images from gallery?
I want to call this:
Uri[] originalUri = data.getData();
But in reality I'm getting this  only, fetching only one Uri:
 Uri originalUri = data.getData();
How to read/retrieve paths or Uri[] when I select multiple images from gallery?
I want to call this:
Uri[] originalUri = data.getData();
But in reality I'm getting this  only, fetching only one Uri:
 Uri originalUri = data.getData();
@RIT as said by you that you want to get multiples images in andorid kitkat .
I have try below code which work for me for Xperia M2 4.4.4
For start image selection activity
private void startImageSelection(){
        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"), PICK_IMAGES);
    } 
But user need to select images by long press
Now to read selected images Uri use below code for onActivityResult
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        if(requestCode==PICK_IMAGES){
            if(resultCode==RESULT_OK){
                //data.getParcelableArrayExtra(name);
                //If Single image selected then it will fetch from Gallery
                if(data.getData()!=null){
                    Uri mImageUri=data.getData();
                }else{
                    if(data.getClipData()!=null){
                        ClipData mClipData=data.getClipData();
                        ArrayList<Uri> 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);
                        }
                        Log.v("LOG_TAG", "Selected Images"+ mArrayUri.size());
                    }
                }
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
 
    
    for selecting multiple images from gallery you can use the following code
String[] projection = {
        MediaStore.Images.Thumbnails._ID,
        MediaStore.Images.Thumbnails.IMAGE_ID
};
mCursor = getContentResolver().query(
        MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
        projection,
        null,
        null,
        MediaStore.Images.Thumbnails.IMAGE_ID + " DESC"
);
columnIndex = mCursor.getColumnIndexOrThrow(projection[0]);
 
    
    Cursor cursor = this.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null,
                null, null);
        cursor.moveToFirst();
        for (int i = 0; i < cursor.getCount(); i++) {
            cursor.moveToPosition(i);
            int cols = cursor.getColumnCount();
            String columns = null;
            for (int j = 0; j < cols; j++) {
                columns += cursor.getColumnName(j) + " | ";
            }
            imagePathUriList.add(cursor.getString(1));
        }
 
    
    here's my take of it in Kotlin. This call is from a fragment, and should work in an activity with little to no tweaking.
//const lives in companion or above class definition
private const val PHOTO_PICKER_REQUEST_CODE = 36
private fun launchPhotoPicker() {
    Intent(Intent.ACTION_PICK).apply {
        putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
        type = "image/*"
    }.let {
        startActivityForResult(it, PHOTO_PICKER_REQUEST_CODE)
    }
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    if (requestCode == PHOTO_PICKER_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            val selectedPhotoUris = mutableListOf<Uri>()
            data?.data?.let {
                selectedPhotoUris.add(it)
            }
            data?.clipData?.let { clipData ->
                for (i in 0 until clipData.itemCount) {
                    clipData.getItemAt(i).uri.let { uri ->
                        selectedPhotoUris.add(uri)
                    }
                }
            }
            //data.data is usually the first item in clipdata
            //I prefer to not make assumptions and just squash dupes
            //I don't trust like that
            val uris = selectedPhotoUris.distinctBy { it.toString() }
            handlePhotoUris(uris)
        }
    }
    super.onActivityResult(requestCode, resultCode, data)
}
private fun handlePhotoUris(uris: List<Uri>) {
    Log.d("photoPicking", "handle uris size: ${it.size}")
    //do stuff here
}
