Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-4235

Android: taking a picture crashes app on Sony Xperia X10

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Needs more info
    • Affects Version/s: Release 1.6.2
    • Fix Version/s: Sprint 2011-23
    • Component/s: Android
    • Labels:
    • Environment:

      Sony Xperia X10 mini, Android 2.2, TiSDK 1.6.2
      Sony Xperia X10, Android 2.2, TiSDK 1.6.2

      Description

      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

      app.js

      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.<init>(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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jalter Jon Alter
                Reporter:
                jalter Jon Alter
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-3641
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code