Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maximum image selection limit from gallery Android

I am trying to get image's Uri in the Gallery built-in app from inside my application.

so, I was using the Intent below, but it selected many more image.

i want to set limitation. less than 3

@Override
public void onClick(View v) {
    Intent intent = new Intent( );
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    startActivityForResult(Intent.createChooser(intent, "select images"), PICK_IMAGE_MULTIPLE);
}

how do i fix this.

Do you have any suggestions?

like image 486
bubu uwu Avatar asked Nov 09 '15 08:11

bubu uwu


1 Answers

Unfortunately, as stated by http://developer.android.com/reference/android/content/Intent.html#EXTRA_ALLOW_MULTIPLE, this is not possible.

This is a boolean extra; the default is false. If true, an implementation is allowed to present the user with a UI where they can pick multiple items that are all returned to the caller.

You'll have to manually check the returned data to see if it's more than 3 items, and if so, show a Toast and let them try again.

like image 80
Daniël van den Berg Avatar answered Oct 19 '22 02:10

Daniël van den Berg