navigator.camera.getPicture doesn’t call success callback - ionic framework - cordova

别说谁变了你拦得住时间么 提交于 2019-12-11 13:36:11

问题


I am using navigator.camera for taking pictrues. The success and error call back is not getting called most of the time. I have installed cordova camera plugin

I am using

ionic 1.2.8

cordova 3.5.0-0.2.7

org.apache.cordova.camera 0.3.3 "Camera"

Shown below is the code I use.

$scope.takePicture =  function takePicture()    {
    var success = function onSuccess (FILE_URI){
    console.log("something" + FILE_URI)
    console.log(FILE_URI);
    $localstorage.setObject("file",FILE_URI);
    $rootScope.picData = FILE_URI;
}

var error = function onError () {
    console.log("Error")
    alert("error")
}

console.log("Taking picture");
navigator.camera.getPicture(success,error,{
            quality: 50,
            destinationType: navigator.camera.DestinationType.FILE_URI,
            sourceType: navigator.camera.PictureSourceType.CAMERA
        });

};


回答1:


It started working perfectly when I disconnected my phone from my system. Something wrong was happening when my phone was in developer mode.

Given below are few links which might help others facing similar issue

PhoneGap camera restarts the application

How to prevent Android to restart application after calling camera intent?

Cordova / Samsung Galaxy SIII - Camera Crashes app

Phonegap camera android kills cordova

Cordova plugin callback received after second plugin call

Posting this here so that this will help someone else. :)



来源:https://stackoverflow.com/questions/27404748/navigator-camera-getpicture-doesn-t-call-success-callback-ionic-framework-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!