How to pick multiple image from gallery Android -
private static final int pick_from_gallery = 2; private void firegallerypick() { 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"), pick_from_gallery); } public void onactivityresult(int requestcode, int resultcode, intent data) { switch (requestcode) { case pick_from_gallery: if (resultcode == -1) { system.out.println("gallery pick success"); string[] all_path = data.getstringarrayextra("all_path"); //but returns null break; } } }
i can able select multiple images , when done selection. need path of selected files in string[]
. in advance.
intent = new intent(action.action_multiple_pick); startactivityforresult(i, 200);
and image-paths in onactivityresult, -
@override public void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == 200 && resultcode == activity.result_ok) { string[] all_path = data.getstringarrayextra("all_path"); (string string : all_path) { string sdcardpath = string; }
note: extra_allow_multiple option available in android api 18 , higher.
Comments
Post a Comment