Ng-cordova camera app restarting app on first time

I am using ng-cordova camera plugin to click picture but after clicking picture app get restart

Code:

$scope.getPhoto = function() {
     var options = { 
      quality : 50, 
      destinationType : Camera.DestinationType.NATIVE_URI, 
      sourceType : Camera.PictureSourceType.CAMERA, 
      allowEdit : false,
      encodingType: Camera.EncodingType.JPEG,
      targetWidth: 300,
      targetHeight: 300,
      popoverOptions: CameraPopoverOptions,
      saveToPhotoAlbum: true
    };
    if(typeof $scope.lastPhoto === 'undefined') {
      $scope.lastPhoto = [];
    }

    console.log("Inside get photo");
    $cordovaCamera.getPicture(options).then(function(imageURI) {
      console.log("Inside Home Control Camera");
      console.log(imageURI);
      $scope.lastPhoto.push(imageURI);
        //$scope.lastPhoto = imageURI;
        console.log( $scope.lastPhoto);
        //$scope.lastPhoto = imageURI;

      }, function(err) {
        console.log("error in camera");
        console.err(err);
      });
  };

Neither success nor error function is calling after clicking picture app just restarts.
I tried to find answers - I find this http://stackoverflow.com/a/27428455/1622022 but these solution does not solve this problem.

If anyone know solution please share .

Thanks

In which device are you testing the app? There is a known issue in some Android devices that when the camera is triggered your app activity goes background and when the picture is taken the device erroneously kills the activity to free memory.

I found this bug in the Moto G 2014.

There is a plugin that might fix your problem called Foreground Camera Plugin

I am using Redmi 1s (Android v4.3) .

Then I tried http://plugreg.com/plugin/econejer/ForegroundCameraGallery this plugin , it is working on Redmi but crashing on Nexus 5 .

Have you tested Foreground Camera Plugin app on different devices? and what the link for above plugin.

Thanks

You can try this plugin: https://github.com/shaithana/cordova-plugin-wezka-nativecamera

Is a fork of the official Camera plugin but only for Android to prevent your app from being killed.

Hope it helps. :wink:

Thanks xMarston I also need Forground Gallery , do you know any?

Even i am facing the similar issue, has any one resolve this?