Mobile App Development: Android Media Picker Library To Pick Photos And Videos

1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 5.00 out of 5)


In your Android application, have you ever written code to allow your users to pick photos & videos from devices via gallery app or camera app? If you have, you might have encountered various different nasty bugs when you tried to get them to work with many Android devices?This is because there are many Android devices from many mobile phone manufacturers and the gallery logic or camera logic are customized by the manufacturers.

In this tutorial, we will show you a solution to deal with this problem and introduce an Android Media Picker Library which helps you pick photos and videos conveniently.

Tung Dao Xuan,, is the author of this article and he contributes to RobustTechHouse Blog



Android Media Picker Library Video


Source Code

You can find the source code at GitHub.


Solution – Android Media Picker Library

Where possible, you should avoid working directly with gallery app because it depends on the manufacturer. Instead, you should work with the Media Store provider in Android which is independent of the manufacturer. This content provider contains meta data for all available media on both internal and external storage devices.

For more details on Content Providers in Android, please check out this link Android Content Providers.

Here are some of the features of the Android Media Picker Library we will show here:

  • Allows you to pick one or multiple photos or videos
  • Options to crop photo.
  • Options for pick video.
  • Use with Activity or Fragment.


How to use Android Media Picker Library

Step 1: Add library

  • Add MediaPicker library to your project.
  • Add MediaPickerActivity into AndroidManifest.xml of your project.

Step 2: Start activity to pick photos or videos

Use the methods in to pick photos or videos


Eg: Start activity to pick photo with crop options.


Eg: Start activity to pick multiple videos.


To find out more detail about options available, you can look into the class.



Step 3: Receive photos or videos

Override onActivityResult(int requestCode, int resultCode, Intent data) method in your Activity or Fragment that pick photos or videos by using code below.

To get information from the item selected, you can call the following:

To know more details, you can check out class.



Android platforms are very fragmented which makes it really challenging when you are designing your Android app. In your applications, you should avoid using apps and components that depend on specific manufacturers.  Hope this tutorial is useful for you and as a developer and hopefully you will find it easier to write code to allow your app users to pick photos, videos on Android with our Android Media Picker Library.

Happy coding!



RobustTechHouse is a leading tech company focusing on mobile app development in Singapore. If you are interested to engage RobustTechHouse on your projects, you can contact us here.



Recommended Posts
  • harin kaklotar

    Hey how to import this project library in to android studio?

  • Sundeep Vig

    Some of the thumbnails do not show up correctly in the picker. The picker needs to rotate the thumbnails based on the Exif info.

  • sanz

    how to import import project library into android studio projects


  • Sudara Madushan

    Better if you can provide a gradle option to import this library to Android Studio

Contact Us

We look forward to your messages. Please drop us a note for any enquiries and we'll get back to you, asap.

Not readable? Change text. captcha txt
HackerNewsVNArtificial Intelligence