Select multiple images from Photo Gallery on Android using Intents

前端 未结 4 550
灰色年华
灰色年华 2020-12-01 06:23

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

In         


        
4条回答
  •  情深已故
    2020-12-01 06:56

    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

提交回复
热议问题