Android Image Picker and Crop Demo

person Vinothkumar Arputharajfolder_openAndroidaccess_time November 4, 2017

Most of the mobile applications use Image Picker and Crop actions. You may find lots of demos and libraries on the internet. This is another attempt to give you a simple and clean implementation of image picker and image crop using a gist available on GitHub and an image crop library by @ArthurHub.

See the following:

  1. In ImagePickerActivity class, collect all camera intents, collect all gallery intents, and collect document intent.
  2. Declare android.permission.CAMERA permission in Manifest.
  3. In CropImageActivity you can pass aspect ratio as intent extra.


1. Dependencies

Add the below line in your module’s build.gradle file:

Do Gradle Sync your project.


2. app/build.gradle

Your app/build.gradle  will look similar to this.


3. Manifest File

We have to add  android.permission.CAMERA  metadata to the manifest file.


4. Check for CAMERA permission at Runtime

Since we will be using camera apps to capture an image, we need to request CAMERA permission at runtime if you are targeting Marshmallow or later versions of Android.


5. Start ImagePickerActivity

Start the ImagePickerActivity for result and get it will call CropImageActivity internally. But if you want to configure it, you can add one extra to the intent and in ImagePickerActivity you can either call Crop or simply get the captured image.


6. Layout for MainActivity




8. Demonstration

Image Picker Intent Chooser
Image Picker Intent Chooser
Image Crop
Image Crop
Image Picker and Crop Demo
Image Picker and Crop Demo

Leave a Reply

Your email address will not be published. Required fields are marked *

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="">