android - How to store images in phone gallery after capture -
by these code can turn on camera , capture image. after capturing image image can show on activity. can not store image on mobile storage. want store image on mobile gallery after capturing. thanks.
public class mainactivity extends appcompatactivity { private static final int camera_request = 1888; private imageview imageview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); this.imageview = (imageview) this.findviewbyid(r.id.imageview1); button photobutton = (button) this.findviewbyid(r.id.button1); photobutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_request); } }); } protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == camera_request && resultcode == activity.result_ok) { bitmap photo = (bitmap) data.getextras().get("data"); imageview.setimagebitmap(photo); } } }
you need give permission in manifest file.
Comments
Post a Comment