how to show image that is last captured from camera in android? -
i using following code in onactivityresult not working
file file1 = new file( environment.getexternalstoragedirectory().getabsolutepath(),imagecapture); if (file1.exists()) { //do action image=(imageview)findviewbyid(r.id.image); bitmap mybitmap = bitmapfactory.decodefile(file1.getabsolutepath()); image.setimagebitmap(mybitmap); image.invalidate(); } but not able why not working have used android camera intent: how full sized photo? gives error on line mimageuri = uri.fromfile(photo); appreciated.
import android.app.activity; import android.content.intent; import android.graphics.bitmap; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.imageview; public class mainactivity extends activity { /** called when activity first created. */ button btntakephoto; imageview imgtakenphoto; private static final int cam_requrest = 0; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); btntakephoto = (button) findviewbyid(r.id.button1); imgtakenphoto = (imageview) findviewbyid(r.id.imageview1); btntakephoto.setonclicklistener(new btntakephotoclicker()); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { // todo auto-generated method stub super.onactivityresult(requestcode, resultcode, data); if (requestcode == camera_pic_request) { bitmap thumbnail = (bitmap) data.getextras().get("data"); imgtakenphoto.setimagebitmap(thumbnail); } } class btntakephotoclicker implements button.onclicklistener { @override public void onclick(view v) { // todo auto-generated method stub intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_pic_request); } } }
Comments
Post a Comment