so trying achieve opening gallery
in android , let user select multiple images
. question has been asked frequently i'm not satisfied answers. because found interesting in de docs in ide (i come on later) , thereby don't want use custom adapter vanilla one.
now code selecting 1 image is:
intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent,"select picture"), 1);
now people on , other websites wil tell you have 2 options:
1) not use action_get_content
action_send_multiple
instead.
1 doesn't work. 1 according docs sending
files , not retrieving
, that's does. when using action_send_multiple got window opened @ device have select application send data to. that's not want, wonder how people got achieved solution.. miss something?
2) implement custom gallery
. last option consider because imho it's not searching because have style myself , why heck can't select multiple images in vanilla gallery?
there must option this.. interesting thing i'v found this:
i found in docs description of action_get_content
.
if caller can handle multiple returned items (the user performing multiple selection), can specify extra_allow_multiple indicate this.
this pretty interesting. here referring use case user can select multiple items?
later on in docs:
you may use extra_allow_multiple allow user select multiple items.
so pretty obvious right? need. following question is: can put extra_allow_multiple
? sad thing can't find no in developers.android guide , not defined constant in intent class.
anybody can me out extra_allow_multiple
?
the extra_allow_multiple option set on intent through intent.putextra() method:
intent.putextra(intent.extra_allow_multiple, true);
your code above should 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);
note: extra_allow_multiple
option available in android api 18 , higher.
Comments
Post a Comment