java - BitmapFactory open failed: ENOENT (No such file or directory) -
i trying take photo android camera intent shown in tutorial: http://developer.android.com/training/camera/photobasics.html#taskscalephoto
the photo taken , safed @ given path. anyway i'm getting following error:
06-25 14:46:02.228 9070-9070/de.ema.flo.grapp e/bitmapfactory﹕ unable decode stream: java.io.filenotfoundexception: file:/storage/emulated/0/android/data/de.ema.flo.grapp/files/pictures/img_20150625_144559002.jpg: open failed: enoent (no such file or directory)
create image:
private file createimagefile() throws ioexception { string timestamp = new simpledateformat("yyyymmdd_hhmmsssss").format(new date()); file storagedir = getactivity().getexternalfilesdir(environment.directory_pictures); file image = new file(storagedir, "img_" + timestamp + ".jpg"); mcurrentphotopath = "file:" + image.getabsolutepath(); return image; }
following code called after taking photo in intent
@override public void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == action_take_photo_b && resultcode == activity.result_ok) { if (mcurrentphotopath != null) { imageview mimageview = (imageview) getactivity().findviewbyid(r.id.grillplatz_erstellen_image); bitmap bitmap = bitmapfactory.decodefile(mcurrentphotopath); // associate bitmap imageview mimageview.setimagebitmap(bitmap); mcurrentphotopath = null; } } }
i tried instead. result same: filenotfoundexception...
try { inputstream = new fileinputstream(file); bitmap bitmap = bitmapfactory.decodestream(is); } catch (filenotfoundexception e) { e.printstacktrace(); }
are there problems code? try change?
please check updated code.
private file createimagefile() throws ioexception { string timestamp = new simpledateformat("yyyymmdd_hhmmsssss").format(new date()); file storagedir = getactivity().getexternalfilesdir(environment.directory_pictures); if(!storagedir.isexist) storagedir.mkdirs(); file image = new file(storagedir, "img_" + timestamp + ".jpg"); mcurrentphotopath = "file:" + image.getabsolutepath(); return image; }
let me know if or not.
Comments
Post a Comment