Select and Share Multiple Images

Select and Share Multiple Images

Today we are going to learn how to select multiple images from our own created gallery because default gallery doesn’t support us to fetch selected images. So for this we need to create our own gallery and select images and do whatever we want like whatsapp, hike and other app doing.

Another way of doing this thing is to make our app sharable so that we can share multiple images from gallery to our own app.

So today we are going to do both things.

Prerequisite for this tutorial:

  • Custom GridView –  Since we are creating Custom Gallery so we need to create Custom GridView with CheckBoxes.
  • Fetch Images –  To display all images into our GridView then we should know how to fetch images.
  • Shareable Activity – How to create our Activity shareable so that other apps can share multiple images to our activity.


In this tutorial, we are going to create Custom Gallery for selecting multiple images and also how to make our app shareable for multiple images.

Video Demo

1. Create a new project in Android Studio by navigating to File ⇒ New ⇒ New Project and fill required details. By default my activity is

2. We are using UniversalImageLoader library for loading images faster and efficiently and you can get the library from the link given. Below are steps to include library:

  • Download the library.
  • Create a new folder under your main project file naming libraries.
  • Copy the library folder from downloaded file and add paste into libraries folder.
  • Now go to your settings.gradle and add the below line and sync your gradle.
  • Now right click on your project and select Open Module Settings -> app -> dependencies -> press “+” icon -> Module dependency -> select your library and press ok.
  • If you want to skip above step then you can go to build.gradle inside app folder and add the below code inside dependencies bracket and sync gradle.
3. Open res ⇒ values ⇒ strings.xml and add below string values. These are some strings that we are going to use in our project.
4. Now, create an xml layout naming activity_main.xml for In this layout i had taken a Button for opening Custom Gallery and GridView for displaying selected images.
5. Create a gridview_layout.xml and add the following code. We create this layout for GridView and include this into other xml files.
6. Now, create a new xml file naming customgallery_activity.xml and add the following code. This layout is for our custom gallery.
7. Since we are using custom gridview so we need create a layout for custom view naming customgridview_item.xml.
8. Now create a java class naming and extend it with Application. In this class we initialise our ImageLoader library configurations so that we don’t need to it initialise every time but only single time here.
9. Now create a new java class naming and add the following code. In this code we fetch all images in our phone by date wise and load over GridView. If user click on button then our MainActivity will open and display selected images.
10. Create a new custom adapter class for GridView naming and add the following line. In this we load the passed image over ImageView by using ImageLoader library.
11. Now in MainActivity we will get the selected images from Custom Gallery in onActivityResult() method. Set all image array for loading over gridview.
12. Second thing we are doing if someone share multiple images to our MainActivity then how to get all images the code is shown below:
13. Finally come to your and add the following code. In this code we are reading images from Custom Gallery and also if someone share images from their app.
14. Now main thing to make our app multiple image shareable we have to add some intent filter inside our activity in AndroidManifest.xml and READ_EXTERNAL_STORAGE permission to read storage data.
And use your MyApplication in application name that we had created in above steps.
15. Now, you are all done, run your app and you will get the output as shown in video.

Thanks. :)

Download Source Code – >

About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.


Hi m not able to add library could you please help


    Hi Prakhar,

    What error you are facing can you tell me?

      Hi Friend i need your help.

      Hi Kuldeep,

      How can i help you?



    I am facing the same problem as well


Thank you so much for this code.
right now i want to upload selected images in mysql database so please help me…!


thank you so much for tutorial.
but how to display images from a folder assets android studio project too ?


Thank you so much for this code! you are awesome. I loved the part where you can just select all items from the Gallery itself, and share load it in Main Activity, which means you can just use this code for those who do not want to build their custom gallery.

Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent,”Select Picture”), 1);


gridView recycling views is creating problem. if i select an image and scroll down, some other images are selected. how to solve this problem. how to properly handle recycling of views and restore the state of existing views when the gridView is recycling views.

    Hi Pradeep Kumar,

    For saving selected view instance you have to create a boolean variable and on selection of view set the boolean value to true and on unselection set back to false. For check box use this boolean value for check and uncheck and by-default it will be false for every view.



How to send multiple images to server php from android


Could someone specify the path where to copy the libraries with the image loader folder ? it keeps showing error that path not found ?


when i try to select image again it deleted the pervious selection ,how saving the pervious images and adding to them?

    Hi Fatima,

    To retain the previously selected images you need to create one Global List of String type and add the selected images into it. Like in OnActivityResult method:

    list_name.addAll(new ArrayList(selectedImages));

    In this way you can maintain the selected images.



how to send selected multiple images from gridview to display in other activity .


there is an error while adding library
Configuration with name ‘Default’ not found


Thank you, but i am getting an error while running the app in the CustomGallery_Activity.

This is where the application gets closed:
Cursor imagecursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy + ” DESC”);//get all data in Cursor by sorting in DESC order

Do You have a suggestion how to solve it?



Work fine now!
Thank you for your help, Dr Droid!

Have a nice day


Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)