App-type: mobile Titanium SDK version: 3.1.1 (06/15/13 16:09 f7592c1) Platform Android Device: Android physical device (samsung S2) OS: Windows Titanium Studio: build: 3.1.0.201304151600
I have a tableView with 5 to 15 rows. Every row shows a default image (about 1-10kb). When the user click the row, a popup window opens, where he can decide to abbort or to take a photo. he can choose between take a new photo, or take a photo from galery. If he decides to take a photo, the camera opens. On Success, i take the event.media and write 2 files. First image should be very small, to show it in the tableview and the second should be medium size, to send them via e-mail in the next steps. my problem is, that the "imageAsResized" method sometimes throw a memory error or before that step, the app restarts after taking the photo an click save/accept.
Titanium.Media.showCamera({ //we got something success : function(event) { Ti.API.info('#### Camera Success'); //checking if it is photo if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { self.dataArr['data'][targetRow.id]['saved_image'] = null; self.dataArr['data'][targetRow.id]['saved_image_small'] = null; self.dataArr['data'][targetRow.id]['saved_image'] = "pic" + targetRow.index + ".jpg"; self.dataArr['data'][targetRow.id]['saved_image_small'] = "pic" + targetRow.index + "_small.jpg"; filePath_big = Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + self.dataArr['data'][targetRow.id]['saved_image']; Ti.API.log("filePath_big: " + filePath_big) filePath_small = Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + self.dataArr['data'][targetRow.id]['saved_image_small']; Ti.API.log("filePath_small: " + filePath_small) smallImage = resizeImage(event.media, 100); smallFile = Titanium.Filesystem.getFile(filePath_small); if (smallFile.exists()) smallFile.deleteFile(); smallFile.write(smallImage); Ti.API.log("smallFile-SIZE: " + Number(smallFile.getSize()) / 1024 + "kb"); targetImageCon.remove(targetImageCon.children[0]); targetImageCon.add(Ti.UI.createImageView({ image : smallFile, defaultImage : smallFile, touchEnabled : false, top : '2dp', bottom : '2dp', left : '2dp', right : '2dp', })); bigImage = resizeImage(event.media, 800); bigFile = Titanium.Filesystem.getFile(filePath_big); if (bigFile.exists()) bigFile.deleteFile(); bigFile.write(bigImage); Ti.API.log("bigFile-SIZE: " + Number(bigFile.getSize()) / 1024 + "kb"); bigImage = null; bigFile = null; filePath_big = null; targetRow.rightImage = preamble + "row_check.png"; Ti.API.log("Ti.platform.availablememory: " + Ti.Platform.availableMemory); } }, cancle : function(event) { //user cancelled the action fron within the camera Ti.API.info('#### Camera Cancel'); }, error : function(event) { // create alert Ti.API.info('#### Camera Error'); var a = Titanium.UI.createAlertDialog({ title : 'Camera' }); // set message if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Device does not have video recording capabilities'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, saveToPhotoGallery : false, });