This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
ImagePicker Class
Abdullah Alhazmy edited this page Sep 11, 2016
·
1 revision
After adding the library, you need to:
- Create an object from
ImagePicker
- Override
onActivityResult
to receive the path of image.
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();
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
}
}