The api multipleImagePicker allows multiple image selection, we can limit the number of images and size of images according to requirement.
- Copy folder in the project root directory.
for example
Project_Name/MultipleImagePicker
- Now go in the settings.gradle file and replace
include ':app'with
include ':app',':multipleImagePickerLib'- Open app's build.gradle file and add the compile project (path:':logger') line in depencies module such as :
dependencies {
compile project(path: ':multipleImagePickerLib')
}- No limit on size and number of images.
- Limit on both size and number of images.
- Limit on size of images only.
- Limit on number of images only.
- if user require limitation on both then pass intent like following
Intent galleryActivity = new Intent(MultipleImagePickerActivity.this, AlbumActivity.class);
//size in MB
galleryActivity.putExtra(GalleryConstants.SIZE,10);
//pass max number of images can be selected
galleryActivity.putExtra(GalleryConstants.NUMBER_OF_IMAGES, 10);
startActivityForResult(galleryActivity, AlbumActivityRequest);
- if user don't require any limitation then pass intent like following
Intent galleryActivity1 = new Intent(MultipleImagePickerActivity.this, AlbumActivity.class);
startActivityForResult(galleryActivity1, AlbumActivityRequest);
- if user require limitation on number of images only then pass intent like following
Intent galleryActivity2 = new Intent(MultipleImagePickerActivity.this, AlbumActivity.class);
galleryActivity2.putExtra(GalleryConstants.NUMBER_OF_IMAGES, 10);
startActivityForResult(galleryActivity2, AlbumActivityRequest);
- if user require limitation on size of images only then pass intent like following
Intent galleryActivity3 = new Intent(MultipleImagePickerActivity.this, AlbumActivity.class);
galleryActivity3.putExtra(GalleryConstants.SIZE,10);
startActivityForResult(galleryActivity3, AlbumActivityRequest);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AlbumActivityRequest) {
if (resultCode == RESULT_OK) {
//it return the list of selected images
Log.d("MultipleImagePicker", "selectred image path list is" +
data.getStringArrayListExtra(GalleryConstants.SELECTED_PATH_LIST));
GridView gridView = (GridView) findViewById(R.id.gridView);
GridAdapter gridAdapter = new GridAdapter(MultipleImagePickerActivity.this,
data.getStringArrayListExtra(GalleryConstants.SELECTED_PATH_LIST));
gridView.setAdapter(gridAdapter);
}
}
```