Skip to content

Android library project for providing multiple image selection from the device.

License

Notifications You must be signed in to change notification settings

shuaibin-lam/poly-picker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poly-picker

Android library project for selecting/capturing multiple images from the device.

Why?

  • Most of the apps we develop require to fetch images from camera or gallery.
  • Android does not provide multi-selection of images out of the box until API 18.
  • There are no libraries that help me multi-choose images from both camera and gallery with beautiful UX.

Features

  • Allows taking pictures from camera as well.
  • Multi-selection of images from gallery.
  • Ability to select/capture images upto a specified limit.
  • Preview thumbnails of selected images.
  • No dependency.

Result

Getting started

Add camera permissions and required features to your AndroidManifest.xml

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Declare the PolyPicker activity in your AndroidManifest.xml

<activity
            android:name="nl.changer.polypicker.ImagePickerActivity"
            android:configChanges="mcc|mnc|touchscreen|orientation|uiMode|screenSize|keyboardHidden" />

Start the PolyPicker activity and get the result back.

private void getImages() {
	Intent intent = new Intent(mContext, ImagePickerActivity.class);
	intent.putExtra(ImagePickerActivity.EXTRA_SELECTION_LIMIT, 3);	// allow only upto 3 images to be selected.
	startActivityForResult(intent, INTENT_REQUEST_GET_IMAGES);
}

@Override
protected void onActivityResult(int requestCode, int resuleCode, Intent intent) {
	super.onActivityResult(requestCode, resuleCode, intent);

	if (resuleCode == Activity.RESULT_OK) {
		if (requestCode == INTENT_REQUEST_GET_IMAGES) {
			Parcelable[] parcelableUris = intent.getParcelableArrayExtra(ImagePickerActivity.EXTRA_IMAGE_URIS);
            
            if(parcelableUris == null) {
            	return;
            }

            // show images using uris returned.
		}
	}
}

Contributing

Please fork this repository and contribute back using pull requests.

Please follow Android code style guide

Developed by

Credits

This project is inspired by and modified from an existing project mentioned below.

android-multiple-image-picker

Alternative projects

About

Android library project for providing multiple image selection from the device.

Resources

License

Stars

Watchers

Forks

Packages

No packages published