Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

ImagePicker Class

Abdullah Alhazmy edited this page Sep 11, 2016 · 1 revision

After adding the library, you need to:

  1. Create an object from ImagePicker
  2. Override onActivityResult to receive the path of image.

Create an ImagePicker

You will need to create a new instance of ImagePicker. Once the instance are configured, you can call build().

        new ImagePicker.Builder(MainActivity.this)
                        .mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
                        .compressLevel(ImagePicker.ComperesLevel.MEDIUM)
                        .directory(ImagePicker.Directory.DEFAULT)
                        .extension(ImagePicker.Extension.PNG)
                        .scale(600, 600)
                        .allowMultipleImages(false)
                        .enableDebuggingMode(true)
                        .build();

Override onActivityResult

In order to receive the path of image, you will need to override onActivityResult .

   @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
            List<String> mPaths = (List<String>) data.getSerializableExtra(ImagePicker.EXTRA_IMAGE_PATH);
            //Your Code
        }
    }