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.