android - PhoneGap App Crash when take a new photo with Camera Plugin -


i'm developing mobile app cordova/phonegap , i've installed camera plugin. able open camera , click image after app crashes. here crash log:

    java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=34, result=-1, data=null} activity {com.phonegap.helloworld/com.phonegap.helloworld.cordovaapp}: java.lang.illegalargumentexception: filename cannot null     e/androidruntime(22226):    @ android.app.activitythread.deliverresults(activitythread.java:3510)     e/androidruntime(22226):    @ android.app.activitythread.handlesendresult(activitythread.java:3553)     e/androidruntime(22226):    @ android.app.activitythread.access$1200(activitythread.java:165)     e/androidruntime(22226):    @ android.app.activitythread$h.handlemessage(activitythread.java:1374)     e/androidruntime(22226):    @ android.os.handler.dispatchmessage(handler.java:99)     e/androidruntime(22226):    @ android.os.looper.loop(looper.java:176)     e/androidruntime(22226):    @ android.app.activitythread.main(activitythread.java:5455)     e/androidruntime(22226):    @ java.lang.reflect.method.invokenative(native method)     e/androidruntime(22226):    @ java.lang.reflect.method.invoke(method.java:525)     e/androidruntime(22226):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1209)     e/androidruntime(22226):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1025)     e/androidruntime(22226):    @ dalvik.system.nativestart.main(native method)     e/androidruntime(22226): caused by: java.lang.illegalargumentexception: filename cannot null     e/androidruntime(22226):    @ android.media.exifinterface.<init>(exifinterface.java:121)     e/androidruntime(22226):    @ org.apache.cordova.camera.exifhelper.createoutfile(exifhelper.java:66)     e/androidruntime(22226):    @ org.apache.cordova.camera.cameralauncher.processresultfromcamera(cameralauncher.java:430)     e/androidruntime(22226):    @ org.apache.cordova.camera.cameralauncher.onactivityresult(cameralauncher.java:610)     e/androidruntime(22226):    @ org.apache.cordova.cordovaactivity.onactivityresult(cordovaactivity.java:784)     e/androidruntime(22226):    @ android.app.activity.dispatchactivityresult(activity.java:5563)     e/androidruntime(22226):    @ android.app.activitythread.deliverresults(activitythread.java:3506)     e/androidruntime(22226):    ... 11 more 

code have used open camera :

   var picturesource; // picture source var destinationtype; // sets format of returned value document.addeventlistener("deviceready", ondeviceready, false);  function ondeviceready() {   // alert("ready-----")   picturesource = navigator.camera.picturesourcetype;   destinationtype = navigator.camera.destinationtype; }  function capturephoto() {   alert(navigator.camera);   navigator.camera.getpicture(onphotodatasuccess, onfail, {     quality: 20,     destinationtype: destinationtype.file_uri,     targetwidth: 200,     targetheight: 200,     savetophotoalbum: true,     sourcetype: picturesource.camera   }); }  function onphotodatasuccess(imageuri) {   // alert("success--");   var smallimage = document.getelementbyid('smallimage');   smallimage.style.display = 'block';   smallimage.src = imageuri;   // smallimage.src = "data:image/jpeg;base64," + imagedata; }  function onfail(message) {   alert('failed because: ' + message); } 

the bug logged in apache cordova.

help!!!

try replacing capturephoto() function (this working code own app):

function capturephoto() {     var options = {         quality: 75,         destinationtype: camera.destinationtype.file_uri,         sourcetype: camera.picturesourcetype.camera,         mediatype: camera.mediatype.camera,         encodingtype: camera.encodingtype.jpeg,         targetwidth: 200,         targetheight: 200,         savetophotoalbum: true     };     navigator.camera.getpicture(onphotodatasuccess, onfail, options); } 

Comments