Hey guys .I know this question has been asked before here and many times on stackoverflow , But still i am struggling here.
First of all congrats and thanks to ionic team for a wonderful HTML5 framework
Well i am working on an app where i need camera functionality. I have seen many examples and applied them but still my app is getting refreshed when i capture image and click on right button.
This is my code
.factory('Camera', ['$q', function($q) {
return {
getPicture: function(options) {
var q = $q.defer();
navigator.camera.getPicture(function(result) {
// Do any magic you need
q.resolve(result);
}, function(err) {
q.reject(err);
}, {
quality:30 ,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
targetWidth: 320,
targetHeight: 320,
saveToPhotoAlbum: false
});
return q.promise;
}
}
}])
Indeed . You put me on right track. Yes i am trying remote debugging in chrome browser.
Sometime i get camera access and captured image but sometime app again get starts. What can be the issue . Is their some memory allocation issue ? if it is how can i resolve it. Any idea.
My code is very similar to yours. I have two buttons, one allowing interaction with the camera itself, and one allowing a user to select a photo from the photo library. Both of these cause a full app refresh. I added alerts throughout the app to test if the full app was restarting and it appears this is the case. I read before that this can be because of a memory issue where android closes out the background app when opening the camera functions to save memory, but this doesn’t seem to be the case with my app as I am getting this error in the simulator as well as on my android phone.
I have tried using navigator.camera.getPicture directly in the controller, as well as in a factory. Currently I am using the ng-cordova $cordovaCamera. Maybe ng-cordova would help in your case? anyone from the Ionic team want to help out?
Finally figured it out on my end. Turns out the anchor tag I was using had a href="*" in it. Changing this to have an empty href as in the following worked for me: