android - Image captured from camera is empty in rare scenario -
sample part of code have used:
@override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == activity.result_ok) { if (requestcode == keys.camera_intent) { // image camera file f = new file(environment.getexternalstoragedirectory() .tostring()); (file temp : f.listfiles()) { if (temp.getname().equals(refimage)) { f = temp; break; } } listofimages.add(f.tostring()); try { displaycapturedimagesfromcamera(); } catch (exception e) { e.printstacktrace(); } } else if (requestcode == 2) { // image gallery } } }
what happening:
- sometimes blank image(nothing there in image , place holder created). when use camera above code
what trying do:
is there way check file has image data in before setting image location
something read contents of file image data
depending on android device , manufacturer android version , camera app using, camera intent needs implemented differently. check out https://github.com/ralfgehrer/androidcamerautil, in particular cameraintenthelperactivity.
Comments
Post a Comment