angularjsionic-frameworkngcordova

IONIC + cordova camera crashing on android


I am running an IONIC app using the camera. It works fine on more powerful devices but crashes the app on lower quality devices. My research tells me that the phone closes the app once it leaves to open the camera to save memory. I have reduced the size and quality of the image but it still crashes.

https://code.google.com/p/foreground-camera-plugin/

The plugin above is a proposed solution that stops the app from closing. But I cant get it to work and I am wondering how it will work with injecting it into IONIC.

So my question is; are there any working solutions to this problem where I dont have to fork my code and will run on IOS and android.

var options = {
                        quality: 50,
                        destinationType: Camera.DestinationType.DATA_URL,
                        sourceType: Camera.PictureSourceType.CAMERA,
                        allowEdit: true,
                        encodingType: Camera.EncodingType.JPEG,
                        correctOrientation: true,
                        targetWidth: 200,
                        targetHeight: 200,
                        popoverOptions: CameraPopoverOptions,
                        saveToPhotoAlbum: false
                    };
                    $ionicPlatform.ready(function ()
                    {
                        $cordovaCamera.getPicture(options).then(function (imageURI) {
                            $scope.updateDBImage(imageURI);
                            return true;

                        }, function (err) {
                            var Popup = $ionicPopup.alert({
                                title: 'Error!',
                                template: err
                            });
                        });
                    });

This is the code I am using.


Solution

  • @Duovili!

    Put the console.log(JSON.stringify(options)); right after defining the 'options'. I was facing similar problem and then I've noticed that destinationType was undefined which leads to a json similar to this:

      {
       "quality" : 80,
       "sourceType" : 1,
       "allowEdit" : false,
       "encodingType" : 0,
       "saveToPhotoAlbum" : true
      }
    

    without the destinationType value. That crashed my application.