android - Activity killed / onCreate called after taking picture via intent -
i trying take picture using intent. problem after taking picture activity, calls startactivityforresult, seems destroyed oncreate called again.
here code taking pictures after clicking imageview, image should replaced:
if (!getpackagemanager().hassystemfeature( packagemanager.feature_camera)) { util.makelongtoast(r.string.lang_no_camera); } else { intent intent = new intent(mediastore.action_image_capture); startactivityforresult(intent, take_item_photo); }
...
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { log.v(tag, "onactivityresult called"); if (requestcode == take_item_photo) { if (data != null) { imageuri = data.getdata(); try { img_photo.setimagebitmap(media.getbitmap( getcontentresolver(), imageuri)); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } else log.w(tag, "data null"); } }
so try take picture , replace image of imageview it. in cases oncreate called after onactivityresult called , new image lost.
help appreciated.
actually camera causes orientation change in activity why activity being destroyed , recreated.
add in manifest file prevent orientation change , activity not destroyed , recreated.
<activity android:name=".youractivity" android:configchanges="orientation|keyboardhidden|screensize" android:screenorientation="portrait" > </activity>
Comments
Post a Comment