image - Crop Intent doesn't work properly in Android -
here intent code select picture , cropping gallery.
int pick_image_request = 100; intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_pick); intent.putextra(mediastore.extra_output, mediastore.images.media.external_content_uri.tostring()); intent.putextra("crop", "true"); intent.putextra("aspectx", 150); intent.putextra("aspecty", 150); intent.putextra("outputx", 150); intent.putextra("outputy", 150); intent.putextra("return-data", true); getactivity().startactivityforresult(intent.createchooser(intent, "complete using with."), pick_image_request);
here onactivityresult
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { int pick_image_request = 100; bundle extras = null; if (requestcode == pick_image_request && resultcode == result_ok) { extras = data.getextras(); } if (extras != null) { bitmap photo = extras.getparcelable("data"); imageview profilephoto = (imageview) findviewbyid(r.id.profileimageview); profilephoto.setimagebitmap(photo); }
these codes above crop&set image successfully. however, doesn't work properly. mean when i'm using 3rd party gallery app instead of using device's default gallery app. doesn't set image. may not getting file path correctly when using gallery app. , how can implement select&crop , set image imageview ? researched on internet nothing solved problem far.
here intent code select picture , cropping gallery.
no, code selecting picture. various extras have on there not part of the action_pick
documentation, or other official documentation, matter.
these codes above crop&set image successfully
not generally.
however, doesn't work properly. mean when i'm using 3rd party gallery app instead of using device's default gallery app.
there thousands of android device models. there no single "default gallery app" of them; there dozens, if not hundreds, of "default gallery app" implementations. none have support random extras trying. also, none have return in data
extra, action_pick
returns uri
in result intent
, covered in the documentation action_pick
.
so , how can implement select&crop , set image imageview ?
get rid of extras. rid of extras.getparcelable("data")
bit. uri
of picked image (data.getdata()
). use in conjunction 1 of various image cropping libraries available android.
Comments
Post a Comment