Search code examples
androidimageandroid-intentgallery

Trying To Pick images From Samsung's Gallery


I want to give to user the option to pick multiple images. This is my code in order to let the user choose the wanted gallery and pick images from there:

 public void pickImages() {

        Intent intent = new Intent( Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

        startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_IMAGE_MULTIPLE);
    }

When I click on the pickImages button, I can choose between the default gallery, like in this case - Samsung's, or Google Photos, Etc...

When I choose Google Photos gallery, I'm able to pick photos, but on the same device (Samsung Galaxy S6 Edge), after I choose Samsung's gallery, I can't pick even one photo, it's just a display of them, no matter how long I click on a photo, it doesn't change.

When I enter Samsung's gallery from their launcher, the display is different, and I'm able to long press in order to select images.

I have also checked on Xiaomi's default gallery, and it worked, I could pick photos.

How can I change it and open the right gallery display?


Solution

  • This is my code in order to let the user choose the wanted gallery and pick images from there

    First, there is nothing in that code that has much to do with a "gallery". Any number of apps can respond to that Intent structure, and those apps do not have to be a "gallery".

    Second, an ACTION_PICK should not specify a MIME type. See the documentation.

    Third, ACTION_PICK does not support EXTRA_ALLOW_MULTIPLE. See the documentation.

    after I choose Samsung's gallery, I can't pick even one photo, it's just a display of them, no matter how long I click on a photo, it doesn't change

    First, there is no requirement that all apps support long-clicks on content.

    Second, a long-click pattern usually only is relevant for a multiple-selection situation, and ACTION_PICK does not support multiple selection.

    But, it's entirely possible that you are seeing a genuine bug in Samsung's app.

    How can I change it

    Well, you could clean up the ACTION_PICK Intent that you are using (remove the setType() and putExtra() calls) and see if that changes anything.

    Or, you could switch to ACTION_GET_CONTENT, which does use setType() and does have the potential of supporting EXTRA_ALLOW_MULTIPLE. There is no requirement that any ACTION_GET_CONTENT implementation support EXTRA_ALLOW_MULTIPLE, and you would not use the Uri (MediaStore.Images.Media.EXTERNAL_CONTENT_URI).

    Or, complain to Samsung about the bug in their app.

    open the right gallery display?

    There is no "right gallery display". What handles a particular implicit Intent (ACTION_PICK, ACTION_GET_CONTENT) is to the user and secondarily the device manufacturer. You don't get a vote.

    You could always build your own gallery-style image-selection UI. This would give you consistent results across devices, but it would be more work.