java - Android cannot finish activity -
i'm writing app using opencv android library. i've created cameraactivity want call, , return image.
public class cameraactivity extends activity implements cvcameraviewlistener2 { private baseloadercallback mloadercallback = new baseloadercallback(this) { @override public void onmanagerconnected(int status) { switch (status) { case loadercallbackinterface.success: { log.i(tag, "opencv loaded successfully"); mopencvcameraview.enableview(); } break; default: { super.onmanagerconnected(status); } break; } } }; @override public void oncreate(bundle savedinstancestate) { ... button snap = (button) findviewbyid(r.id.snap); snap.setonclicklistener(new onclicklistener() { public void onclick(view v) { processvideo(); } }); snap.setonlongclicklistener(new onlongclicklistener() { @override public boolean onlongclick(view v) { processpicture(); return true; } }); } @override public void onpause() { ... } @override public void onresume() { ... } public void ondestroy() { ... } public void oncameraviewstarted(int width, int height) { ... } @override public void oncameraviewstopped() { ... } public mat oncameraframe(cvcameraviewframe cvf) { // grab frame cvf.rgba().copyto(frame); // filter frame filterlaser(); // retrieve contour center point contourlaser(); // draw draw(); // display result. return cvf.rgba(); } private void draw(){ ... } private void filterlaser(){ ... } void processvideo(){ ... } void processpicture(){ intent result = new intent(); if(frame != null) { // convert processed mat bitmap bitmap resultbitmap = bitmap.createbitmap(frame.cols(), frame.rows(),bitmap.config.argb_8888);; utils.mattobitmap(frame, resultbitmap); setresult(activity.result_ok, result); result.putextra("bitmap", resultbitmap); } else { setresult(activity.result_canceled); // no frame found } log.d("lastpoint", "finished"); finish(); } };
this activity gets called using following code in mainactivity.
button reply = (button) findviewbyid(r.id.buttonreply); reply.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent = new intent(getapplicationcontext(), cameraactivity.class); startactivityforresult(i, camerarequest); } });
and result extracted in mainactivity.
@override public void onactivityresult(int requestcode, int resultcode, intent data) { log.d("lastpoint", "writing");
switch(requestcode) { case (camerarequest) : if (resultcode == activity.result_ok) { bitmap bmp = (bitmap) data.getparcelableextra("bitmap"); writebitmap(bmp); } break; } }
"finished" gets printed logcat. "writing" isn't. why can't exit cameraactivity? view isn't closing either.
the problem line:
result.putextra("bitmap", resultbitmap);
solved saving picture sdcard in cameraactivity , passing uri through result intent.
Comments
Post a Comment