Taking a picture crashes app on Sony Xperia X10.
Can be reproduced reliably with Kitchen Sink, by executing "Phone -> Camera -> Camera Basic" and taking a picture.
The example below causes the same error. Only crashes on "Sony Xperia X10".
Step 1: run the code below
Step 2: take a picture
Step 3: notice the app crash
var win = Ti.UI.createWindow({ fullscreen: true });
var cameraOverlay = Ti.UI.createView();
var cameraButton = Ti.UI.createButton({
title:"Take Picture",
bottom: 10
});
cameraButton.addEventListener('click', function(e){
Ti.Media.takePicture();
});
cameraOverlay.add(cameraButton);
var open = Ti.UI.createButton({
title: 'Open',
bottom: 100,
height: 40,
width: 200
});
open.addEventListener('click', function(){
Titanium.Media.showCamera({
success:function(event)
{
var cropRect = event.cropRect;
var image = event.media;
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
var imageView = Ti.UI.createImageView({
width:win.width,
height:win.height,
image:event.media
});
win.add(imageView);
}
else
{
alert("got the wrong type back ="+event.mediaType);
}
},
cancel:function()
{
},
error:function(error)
{
// create alert
var a = Titanium.UI.createAlertDialog({title:'Camera'});
// set message
if (error.code == Titanium.Media.NO_CAMERA)
{
a.setMessage('Please run this test on device');
}
else
{
a.setMessage('Unexpected error: ' + error.code);
}
// show alert
a.show();
},
saveToPhotoGallery:true,
allowEditing:true,
mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
// overlay: cameraOverlay
});
});
win.add(open);
win.open();
Stack Trace:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data dat=file:///sdcard/dcim/Camera/Memonic/tia608277175.jpg typ=image/jpeg (has extras) }} to activity {com.memonic.mobile/org.appcelerator.titanium.TiModalActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:2504)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:2546)
at android.app.ActivityThread.access$2000(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:966)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3652)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at java.io.File.fixSlashes(File.java:205)
at java.io.File.init(File.java:189)
at java.io.File.
(File.java:139)
at ti.modules.titanium.media.MediaModule$CameraResultHandler.onResult(MediaModule.java:318)
at org.appcelerator.titanium.util.TiActivitySupportHelper$1.onResult(TiActivitySupportHelper.java:52)
at org.appcelerator.titanium.util.TiActivitySupportHelper.onActivityResult(TiActivitySupportHelper.java:68)
at org.appcelerator.titanium.TiBaseActivity.onActivityResult(TiBaseActivity.java:354)
at android.app.Activity.dispatchActivityResult(Activity.java:3907)
at android.app.ActivityThread.deliverResults(ActivityThread.java:2500)
... 11 more
Workaround
Use an overlay. In the example above, uncomment "// overlay: cameraOverlay" and the camera will work as expected.
Associated Helpdesk Ticket
http://appc.me/c/APP-791753
Try and reproduce on the Play. If we can't we may have to get the X10.
Closing ticket due to the information that was requested not being provided.