Search code examples
androidgalleryonactivityresult

How to pick multiple files from Android's gallery?


i need to open gallery and pick 1-n images OR 1-n videos (2 different intent) from Android's gallery, like the ACTION_PICK intent. How can I achieve that? There are some cool library on GitHub for multiple pick or custom gallery?


Solution

  • If you use API 18 or higher, you can add to your intent.putExtra like so:

    Intent intent = new Intent();
    intent.setType("image/*,video/*"); //For choosing both images and/or videos
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); //This should allow multiple selection
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);
    

    There is also a GitHub project to build your own GridView with multi selection Read here