bitmap - Facing "fatal error" while saving picture taken in 2nd photo taking; 1st photo taking and picture saving work well -
bitmap - Facing "fatal error" while saving picture taken in 2nd photo taking; 1st photo taking and picture saving work well -
i seek write apps take photo, save photo @ want directory desired name, bitmap photo place @ imagereview. can work in first photo taking, photo saving, photo bitmap , placing image @ image review. while seek redo 2nd time, still can launch photographic camera , take photo, when saving photo, face issue message "unfortunately, xxxxxx has stopped". need helps resolve this. thanks.
i suspect command cause problem below because when commented out command line, don't face problem in 2nd time photo saving: camerabox1.setimagebitmap(capturebmp);
do need add together manage this?
here coding:
takebutton1.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { image = getfile(mainactivity.this); intent = new intent(mediastore.action_image_capture); i.putextra(mediastore.extra_output, uri.fromfile(image) ); startactivityforresult(i, capture_image_capture_code); } }); public file getfile(context context){ final file path = new file( environment.getexternalstoragedirectory(), "my image" ); if(!path.exists()){ path.mkdir(); } string name; int n = 100000; int rand; rand = new random().nextint(n); name = "image-" + rand + ".jpg"; file fileimage = new file(path, name); homecoming fileimage; } protected void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode == result_ok){ toast.maketext(this, "image captured", toast.length_long).show(); switch(requestcode){ case capture_image_capture_code: seek { bitmap capturebmp; capturebmp = media.getbitmap(getcontentresolver(), uri.fromfile(image) ); imageuri = uri.fromfile(image); string pathtoimage = imageuri.getpath(); camerabox1 = (imageview) findviewbyid(r.id.camerabox); camerabox1.setimagebitmap(capturebmp); } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } camerabox1.setscaletype(imageview.scaletype.center_inside); camerabox1.setadjustviewbounds(true); break; } } else if (resultcode == result_canceled) { toast.maketext(this, "cancelled", toast.length_long).show(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); homecoming true; }
api use:
import java.io.file; import java.io.filenotfoundexception; import java.io.ioexception; import java.util.random; import android.app.activity; import android.content.context; import android.content.intent; import android.graphics.bitmap; import android.net.uri; import android.os.bundle; import android.os.environment; import android.provider.mediastore; import android.provider.mediastore.images.media; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.view.view.onkeylistener; import android.widget.button; import android.widget.framelayout; import android.widget.imageview; import android.widget.textview; import android.widget.toast; import android.annotation.suppresslint;
bitmap camera image-capture
Comments
Post a Comment