Lesser-known android lib which is very helpful. Part 2

Hitesh Dhamshaniya
2 min readOct 12, 2019

How difficult to capture an image using a camera or select an image from a gallery.

It is not that much difficult to capture an image using a camera or select an image from a gallery. Android OS provides a simple way to do that in your app via Intent.

that’s it? It is very simple.
wait a minutes, its not end we have manage activity life, get result in onActivityResult method, and their we need to check whether intent.data is null or not. Below is stackoverflow answer for better understanding.

Oh… its bit complex, not that simple what we thought. Wait a minutes we have alternate solution.

Here it is, the best open source library to pick image easily. The best part about that libs is, its maintain in both language java as well as Kotlin. On top of that its also available for androidx and support lib. And the perk of lib is you can easily use it in activity or fragment. We simply need to add lib into our gradle file.

allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
//Make sure to add this in your project for uCrop
}
}
implementation 'com.github.dhaval2404:imagepicker:1.4'If you are did not Migrate on AndroidX yet, Use support build artifact:implementation 'com.github.dhaval2404:imagepicker-support:1.3'

The ImagePicker configuration is created using the builder pattern.

Image Picker, if you are in Java check lib repo on github

Handling results

Default method Override onActivityResult method and handle ImagePicker result.

There is much more, Please visit repo page for more option and customization as per the your requirement.

Please let me know if you find any difficulties to implement that lib, also if its not work for you report, will try best to resolve an issue.

Finally here is repo page, (Thanks man for maintaining ImagePicker lib)

Share it if you like it. Thank you very much for reading.

Hitesh Dhamshaniya
Hitesh Dhamshaniya

Responses (1)

Write a response

Glad you share it. Thanks

--