How to limit multiple image selection from the gallery? The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow do I call one constructor from another in Java?How to get an enum value from a string value in Java?How to pick an image from gallery (SD Card) for my app?Allow user to select camera or gallery for imageReading images from the memory of the phone (no SD)how to add images to resourse/drawable folder in android project dynamicallySelect multiple images from android galleryGet filepath and filename of selected gallery image in AndroidAndroid Image Picker Select multiple images from gallery with a maximum limit of 5In Android how to open system built in gallery app using intent?

What information about me do stores get via my credit card?

number sequence puzzle deep six

Why can't wing-mounted spoilers be used to steepen approaches?

Does Parliament hold absolute power in the UK?

What does "spokes" mean in this context?

Define a list range inside a list

Is there a writing software that you can sort scenes like slides in PowerPoint?

Didn't get enough time to take a Coding Test - what to do now?

Make it rain characters

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Homework question about an engine pulling a train

Does Parliament need to approve the new Brexit delay to 31 October 2019?

What can I do to 'burn' a journal?

Did the new image of black hole confirm the general theory of relativity?

Student Loan from years ago pops up and is taking my salary

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Can withdrawing asylum be illegal?

"... to apply for a visa" or "... and applied for a visa"?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

How did the crowd guess the pentatonic scale in Bobby McFerrin's presentation?

What's the point in a preamp?

Why not take a picture of a closer black hole?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Was credit for the black hole image misappropriated?



How to limit multiple image selection from the gallery?



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow do I call one constructor from another in Java?How to get an enum value from a string value in Java?How to pick an image from gallery (SD Card) for my app?Allow user to select camera or gallery for imageReading images from the memory of the phone (no SD)how to add images to resourse/drawable folder in android project dynamicallySelect multiple images from android galleryGet filepath and filename of selected gallery image in AndroidAndroid Image Picker Select multiple images from gallery with a maximum limit of 5In Android how to open system built in gallery app using intent?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I have implemented adding multiple image selection from the gallery in my project. However, I want to limit the user so he/she can select only 3 images from the gallery.



I have implemented selecting multiple images from the gallery like this:



 `Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1);`


How can I achieve this?



Thanks.










share|improve this question






























    -1















    I have implemented adding multiple image selection from the gallery in my project. However, I want to limit the user so he/she can select only 3 images from the gallery.



    I have implemented selecting multiple images from the gallery like this:



     `Intent intent = new Intent();
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1);`


    How can I achieve this?



    Thanks.










    share|improve this question


























      -1












      -1








      -1








      I have implemented adding multiple image selection from the gallery in my project. However, I want to limit the user so he/she can select only 3 images from the gallery.



      I have implemented selecting multiple images from the gallery like this:



       `Intent intent = new Intent();
      intent.setType("image/*");
      intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
      intent.setAction(Intent.ACTION_GET_CONTENT);
      startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1);`


      How can I achieve this?



      Thanks.










      share|improve this question
















      I have implemented adding multiple image selection from the gallery in my project. However, I want to limit the user so he/she can select only 3 images from the gallery.



      I have implemented selecting multiple images from the gallery like this:



       `Intent intent = new Intent();
      intent.setType("image/*");
      intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
      intent.setAction(Intent.ACTION_GET_CONTENT);
      startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1);`


      How can I achieve this?



      Thanks.







      java android android-gallery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 11 at 10:52









      Fantômas

      32.9k156491




      32.9k156491










      asked Jan 11 at 10:38









      Heisenberg.Heisenberg.

      224




      224






















          3 Answers
          3






          active

          oldest

          votes


















          0














          You can get the count of ClipData when selecting multiple images from and gallery and if that count is grater than 3 you can notify the user about it.



          You can do something like this after selecting images from gallery:



          protected void onActivityResult(int requestCode, int resultCode, Intent data) 
          if(resultCode == RESULT_OK





          share|improve this answer






























            0














            This is not possible.
            https://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE



            You'll have to manually check the returned data to see if it's more than 10 items, and if so, show a Toast






            share|improve this answer






























              0














              put this in your build.gradle(app)



               compile 'com.github.esafirm.android-image-picker:imagepicker:1.5.0'
              compile 'com.github.esafirm.android-image-picker:rximagepicker:1.5.0'


              and this in your activity



              private void pickImage() 
              ImagePicker.create(UploadPhotosActivity.this)
              .showCamera(false)
              .limit(3)
              .imageTitle(getString(R.string.select_image))
              .folderTitle(getString(R.string.folder))
              .theme(R.style.ImagePickerTheme)
              .start(RC_CODE_PICKER);


              @Override
              protected void onActivityResult(int requestCode, int resultCode, Intent data)
              super.onActivityResult(requestCode, resultCode, data);
              if (requestCode == RC_CODE_PICKER)
              Log.d("===uploadPhoto", "gallery : " + data);
              imagesList = (ArrayList<Image>) ImagePicker.getImages(data);
              Intent intent = new Intent(UploadPhotosActivity.this, ImageCropperActivity.class);
              intent.putExtra(ImageCropperActivity.EXTRA_VIEW_PORT_RATIO, imagesList);
              startActivity(intent);

              else
              Intent returnIntent = new Intent();
              setResult(Activity.RESULT_CANCELED, returnIntent);
              finish();

              }





              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function ()
                StackExchange.using("externalEditor", function ()
                StackExchange.using("snippets", function ()
                StackExchange.snippets.init();
                );
                );
                , "code-snippets");

                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "1"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54144821%2fhow-to-limit-multiple-image-selection-from-the-gallery%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                You can get the count of ClipData when selecting multiple images from and gallery and if that count is grater than 3 you can notify the user about it.



                You can do something like this after selecting images from gallery:



                protected void onActivityResult(int requestCode, int resultCode, Intent data) 
                if(resultCode == RESULT_OK





                share|improve this answer



























                  0














                  You can get the count of ClipData when selecting multiple images from and gallery and if that count is grater than 3 you can notify the user about it.



                  You can do something like this after selecting images from gallery:



                  protected void onActivityResult(int requestCode, int resultCode, Intent data) 
                  if(resultCode == RESULT_OK





                  share|improve this answer

























                    0












                    0








                    0







                    You can get the count of ClipData when selecting multiple images from and gallery and if that count is grater than 3 you can notify the user about it.



                    You can do something like this after selecting images from gallery:



                    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
                    if(resultCode == RESULT_OK





                    share|improve this answer













                    You can get the count of ClipData when selecting multiple images from and gallery and if that count is grater than 3 you can notify the user about it.



                    You can do something like this after selecting images from gallery:



                    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
                    if(resultCode == RESULT_OK






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 8 at 12:02









                    3iL3iL

                    4161424




                    4161424























                        0














                        This is not possible.
                        https://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE



                        You'll have to manually check the returned data to see if it's more than 10 items, and if so, show a Toast






                        share|improve this answer



























                          0














                          This is not possible.
                          https://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE



                          You'll have to manually check the returned data to see if it's more than 10 items, and if so, show a Toast






                          share|improve this answer

























                            0












                            0








                            0







                            This is not possible.
                            https://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE



                            You'll have to manually check the returned data to see if it's more than 10 items, and if so, show a Toast






                            share|improve this answer













                            This is not possible.
                            https://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE



                            You'll have to manually check the returned data to see if it's more than 10 items, and if so, show a Toast







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 11 at 10:53









                            Sambhaji KaradSambhaji Karad

                            529517




                            529517





















                                0














                                put this in your build.gradle(app)



                                 compile 'com.github.esafirm.android-image-picker:imagepicker:1.5.0'
                                compile 'com.github.esafirm.android-image-picker:rximagepicker:1.5.0'


                                and this in your activity



                                private void pickImage() 
                                ImagePicker.create(UploadPhotosActivity.this)
                                .showCamera(false)
                                .limit(3)
                                .imageTitle(getString(R.string.select_image))
                                .folderTitle(getString(R.string.folder))
                                .theme(R.style.ImagePickerTheme)
                                .start(RC_CODE_PICKER);


                                @Override
                                protected void onActivityResult(int requestCode, int resultCode, Intent data)
                                super.onActivityResult(requestCode, resultCode, data);
                                if (requestCode == RC_CODE_PICKER)
                                Log.d("===uploadPhoto", "gallery : " + data);
                                imagesList = (ArrayList<Image>) ImagePicker.getImages(data);
                                Intent intent = new Intent(UploadPhotosActivity.this, ImageCropperActivity.class);
                                intent.putExtra(ImageCropperActivity.EXTRA_VIEW_PORT_RATIO, imagesList);
                                startActivity(intent);

                                else
                                Intent returnIntent = new Intent();
                                setResult(Activity.RESULT_CANCELED, returnIntent);
                                finish();

                                }





                                share|improve this answer



























                                  0














                                  put this in your build.gradle(app)



                                   compile 'com.github.esafirm.android-image-picker:imagepicker:1.5.0'
                                  compile 'com.github.esafirm.android-image-picker:rximagepicker:1.5.0'


                                  and this in your activity



                                  private void pickImage() 
                                  ImagePicker.create(UploadPhotosActivity.this)
                                  .showCamera(false)
                                  .limit(3)
                                  .imageTitle(getString(R.string.select_image))
                                  .folderTitle(getString(R.string.folder))
                                  .theme(R.style.ImagePickerTheme)
                                  .start(RC_CODE_PICKER);


                                  @Override
                                  protected void onActivityResult(int requestCode, int resultCode, Intent data)
                                  super.onActivityResult(requestCode, resultCode, data);
                                  if (requestCode == RC_CODE_PICKER)
                                  Log.d("===uploadPhoto", "gallery : " + data);
                                  imagesList = (ArrayList<Image>) ImagePicker.getImages(data);
                                  Intent intent = new Intent(UploadPhotosActivity.this, ImageCropperActivity.class);
                                  intent.putExtra(ImageCropperActivity.EXTRA_VIEW_PORT_RATIO, imagesList);
                                  startActivity(intent);

                                  else
                                  Intent returnIntent = new Intent();
                                  setResult(Activity.RESULT_CANCELED, returnIntent);
                                  finish();

                                  }





                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    put this in your build.gradle(app)



                                     compile 'com.github.esafirm.android-image-picker:imagepicker:1.5.0'
                                    compile 'com.github.esafirm.android-image-picker:rximagepicker:1.5.0'


                                    and this in your activity



                                    private void pickImage() 
                                    ImagePicker.create(UploadPhotosActivity.this)
                                    .showCamera(false)
                                    .limit(3)
                                    .imageTitle(getString(R.string.select_image))
                                    .folderTitle(getString(R.string.folder))
                                    .theme(R.style.ImagePickerTheme)
                                    .start(RC_CODE_PICKER);


                                    @Override
                                    protected void onActivityResult(int requestCode, int resultCode, Intent data)
                                    super.onActivityResult(requestCode, resultCode, data);
                                    if (requestCode == RC_CODE_PICKER)
                                    Log.d("===uploadPhoto", "gallery : " + data);
                                    imagesList = (ArrayList<Image>) ImagePicker.getImages(data);
                                    Intent intent = new Intent(UploadPhotosActivity.this, ImageCropperActivity.class);
                                    intent.putExtra(ImageCropperActivity.EXTRA_VIEW_PORT_RATIO, imagesList);
                                    startActivity(intent);

                                    else
                                    Intent returnIntent = new Intent();
                                    setResult(Activity.RESULT_CANCELED, returnIntent);
                                    finish();

                                    }





                                    share|improve this answer













                                    put this in your build.gradle(app)



                                     compile 'com.github.esafirm.android-image-picker:imagepicker:1.5.0'
                                    compile 'com.github.esafirm.android-image-picker:rximagepicker:1.5.0'


                                    and this in your activity



                                    private void pickImage() 
                                    ImagePicker.create(UploadPhotosActivity.this)
                                    .showCamera(false)
                                    .limit(3)
                                    .imageTitle(getString(R.string.select_image))
                                    .folderTitle(getString(R.string.folder))
                                    .theme(R.style.ImagePickerTheme)
                                    .start(RC_CODE_PICKER);


                                    @Override
                                    protected void onActivityResult(int requestCode, int resultCode, Intent data)
                                    super.onActivityResult(requestCode, resultCode, data);
                                    if (requestCode == RC_CODE_PICKER)
                                    Log.d("===uploadPhoto", "gallery : " + data);
                                    imagesList = (ArrayList<Image>) ImagePicker.getImages(data);
                                    Intent intent = new Intent(UploadPhotosActivity.this, ImageCropperActivity.class);
                                    intent.putExtra(ImageCropperActivity.EXTRA_VIEW_PORT_RATIO, imagesList);
                                    startActivity(intent);

                                    else
                                    Intent returnIntent = new Intent();
                                    setResult(Activity.RESULT_CANCELED, returnIntent);
                                    finish();

                                    }






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jan 11 at 11:25









                                    Kevin KurienKevin Kurien

                                    603213




                                    603213



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54144821%2fhow-to-limit-multiple-image-selection-from-the-gallery%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown