i'm getting runtime exception while getting uri bitmap. btw same code works perfect in standalone project.
call camera intent
private void opencamera() { intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, request_code_capture_image); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == request_code_capture_image && resultcode == getactivity().result_ok && null != data) { bitmap photo = (bitmap) data.getextras().get("data"); string s = getimageuri(photo).tostring(); globals.saveimagepathtosharedpref(getactivity(), s); setimage(uri.parse(s)); } } public uri getimageuri(bitmap inimage) { bytearrayoutputstream bytes = new bytearrayoutputstream(); inimage.compress(bitmap.compressformat.jpeg, 100, bytes); string path = mediastore.images.media.insertimage(getactivity().getcontentresolver(), inimage, "title", null); return uri.parse(path); }
in getimageuri method, path returning null, , exception follows:
java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=327780, result=-1, data=intent { act=inline-data (has extras) }} activity : java.lang.nullpointerexception: uristring
you can use mediastore.extra_output
cameraintent
, full sized image saved location. bitmap returned in intent activity result thumbnail.
you can use environment.getexternalstoragepublicdirectory(environment.directory_pictures)
to generate uri
pass in extra_output
Comments
Post a Comment