Reputation: 10916
[EDIT]
I actually solved this adding the following line to my activity manifest:
android:configChanges="orientation|keyboardHidden"
I'm trying to save an image captured with my android phone using phonegap, however 80% of the time I press the save button, after taking the picture, my app just dies...
I've seen that this is a common problem with phonegap + android. I've already tried lowering the quality of the image, cleaning phone memory, erasing the cache directory of the app... Nothing so far, I still get this random behavior.
I've tried using imageData and imageURI, but still get the error.
Something to note is that everytime I rotate the phone, my app dies. Some times when I save an image, the screen automatically rotates, and that also kill the app.
Here is the code I have so far...
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log(imageURI);
$('#my_div') // this div belongs to my html markup (see bellow)
.empty()
.append(
$('<image>')
.attr('src', imageURI)
.attr('width', '100')
.attr('height', '100')
.css({
'background-color' : 'red',
'-webkit-border-radius': '15px',
'-moz-border-radius': '15px',
'border-radius': '15px'
})
);
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(
function (imageUri) {
onPhotoURISuccess(imageUri, photo_div_id);
},
onFail, {
quality: 30,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: source
}
);
}
<div id="my_div" class= "iconP">
<input type="button" name="photo_1" id="photo_1" onclick ="getPhoto()" value="photo 1"/>
</div>
Upvotes: 0
Views: 401
Reputation: 596
You need to add more to your mainfest than that, otherwise you'll run into this problem again. Add the following: android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
Upvotes: 3