i have android application contains multiple activities.
in 1 of them i'm using button call device camera :
public void onclick(view view) { intent photointent = new intent(mediastore.action_image_capture); startactivityforresult(photointent, image_capture); }
in same activity call onactivityresult
method image result :
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == image_capture) { if (resultcode == result_ok) { bitmap image = (bitmap) data.getextras().get("data"); imageview imageview = (imageview) findviewbyid(r.id.pic); imageview.setimagebitmap(image);} else if (resultcode == result_canceled) {toast.maketext(this, "canceled ", toast.length_long).show();} } }
the problem intent data
null , onactivityresult
method turns directly (resultcode == result_canceled)
, application returns previous avtivity.
how can fix issue , after calling camera, application returns current activity contains imageview
contains picture taken?
thanks
the default android camera application returns non-null intent when passing thumbnail in returned intent. if pass extra_output
uri write to, return null
intent , picture in uri passed in.
you can verify looking @ camera app's source code on github:
-
bundle newextras = new bundle(); if (mcropvalue.equals("circle")) { newextras.putstring("circlecrop", "true"); } if (msaveuri != null) { newextras.putparcelable(mediastore.extra_output, msaveuri); } else { newextras.putboolean("return-data", true); }
i guess you're either passing in extra_output
somehow, or camera app on phone works differently.
Comments
Post a Comment