2

I am using this piece of code to get multiple images from gallery:

    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)), GALLERY_CODE);

But how do I restrict the number of images that can be picked? For example, I only want the user to pick at most 9 images.

Seaky
  • 239
  • 2
  • 13
  • as mentioned in [this answer](https://stackoverflow.com/a/33604995/7948109) it is not possible, you have manually check the return value or like some other Apps you can create your own imagePicker like WhatsApp show's it's own image picker instead of Gallery – Rahul Gaur Dec 23 '19 at 10:18
  • I don't think you can do that by launching `intents` instead I believe you will have to load images from gallery into your app and then you can code logic for allowing user to select max number of images. – Yupi Dec 23 '19 at 10:19
  • Does this answer your question? [maximum image selection limit from gallery Android](https://stackoverflow.com/questions/33604951/maximum-image-selection-limit-from-gallery-android) – Rahul Gaur Dec 23 '19 at 10:20

0 Answers0