android - How can i save the image taken from camera intent to be used as a profile image? -
in app user can take image camera , use profile picture. works, except when user leaves app , returns image isn't there anymore. how can save image stay there when user exits app?
code camera intent:
intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_request);
and onactivityresult
:
protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == camera_request) { bitmap photo = (bitmap) data.getextras().get("data"); getlayoutinflater().inflate(r.layout.custon_header,null); imageview profimg = (imageview) findviewbyid(r.id.roundedimg); profimg.setimagebitmap(photo);
could please assist me this?
thanks
data.getextras().get("data");
only returns thumbnail of image on low quality. have specify on camera intent location image saved:
file outputfile = new file(environment.getexternalstoragedirectory() +"/myoutput.jpg"); intent cameraintent = new intent(android.provider.mediastore.action_image_capture); cameraintent.putextra(intent.extra_output,outputfile.getabsolutepath()); startactivityforresult(cameraintent, camera_request);
and on activityresult, use outputfile bitmap:
bitmap = bitmapfactory.decodefile(outputfile.getabsolutepath());
Comments
Post a Comment