Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (device)
Viewing all articles
Browse latest Browse all 250

Error on use of camera on device nexus 4

$
0
0

Hi All,

I m working on app which will work on ios as well as android. I m using titanium sdk 3.2.1 and alloy framework 1.3.0. I m testing it on nexus 4 right now. I have requirement of using device camera for multiple pics and show them on tableview. I have following code for using camera. Also i m using 'imagefactory' module.

function cameraImageClick(e){
    Titanium.Media.showCamera({
    success:function(event) {
        if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
            var image = event.media;
            var newBlob = ImageFactory.imageAsResized(image, { width: 200, height: 200 , format: ImageFactory.JPG ,quality:0.5});
            var imageView = Ti.UI.createImageView({
                image:newBlob
            });
            $.cameraViewId.add(imageView);
        } else {
            alert("got the wrong type back ="+event.mediaType);
        }
    },
    cancel:function() {
        // called when user cancels taking a picture
    },
    error:function(error) {
        // called when there's an error
        var a = Titanium.UI.createAlertDialog({title:'Camera'});
        if (error.code == Titanium.Media.NO_CAMERA) {
            a.setMessage('Please run this test on device');
        } else {
            a.setMessage('Unexpected error: ' + error.code);
        }
        a.show();
    },
    saveToPhotoGallery:false,
    allowEditing:true,
    mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
    }); 
}
But when i take a picture and press "right" sign, i get following error.
[INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 31.508MB for 15980560-byte allocation
[ERROR] :  TiExceptionHandler: (main) [10608,17657] ----- Titanium Javascript Runtime Error -----
[ERROR] :  TiExceptionHandler: (main) [0,17657] - Message: Uncaught Error: Unable to convert null
[ERROR] :  TiExceptionHandler: (main) [0,17657] - Source:                     var newBlob = ImageFactory.imageAsResized(image, {
[ERROR] :  V8Exception: Exception occurred at alloy/controllers/cameraV.js:11: Uncaught Error: Unable to convert null
can anybody please help me with this? Is this a code problem? Right now i m just testing it on nexus4 and next i will test it on iphone. I m not sure whether it will throw the same error on iphone.

Viewing all articles
Browse latest Browse all 250

Latest Images

Trending Articles





Latest Images