Project: titanium
Issue TIMOB-12848: Android: Using the camera on certain devices causes the app to crash
Call Ti.Media.showCamera and the camera opens up fine, takes the picture fine, then click ok, and the app crashes before reaching the success function. The picture does manage to get saved into the photo gallery. Sample code. Paste this into a new Android application. {code} var win = Titanium.UI.createWindow(); var imageView = Ti.UI.createImageView({height: Ti.UI.FILL, width: Ti.UI.Fill}); win.add(imageView);	Titanium.Media.showCamera({	success:function(event)	{	Ti.API.info('#### Camera Success');	var cropRect = event.cropRect;	var image = event.media;	Ti.API.info(image.length);	var filename = Titanium.Filesystem.tempDirectory + "/"+ 'camera_photo' + new Date().getTime() + ".png";	Ti.API.info(filename);	var f = Titanium.Filesystem.getFile(filename);	Ti.API.info(f.nativePath);	if (f.exists()) {	Ti.API.info('The file exist , trying to delete it before using it :' + f.deleteFile());	f = Titanium.Filesystem.getFile(filename);	}	f.write(image);	alert('Camera Success! The file size is '+f.size+' bytes.\n Now trying to assign it to an image on the screen (this may fail for hi res images)')	imageView.image = f.nativePath;	},	cancel:function()	{	Ti.API.info('#### Camera Cancel');	},	error:function(error)	{	// 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);	}	// show alert	a.show();	},	allowEditing:true	}); win.open(); {code}
Story points: 13