Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Camera Error - "Titanium.Media.NO_CAMERA"

$
0
0

When I click on the "Take Picture" button in my app it is returning the error code "Titanium.Media.NO_CAMERA"...Please run this test on device. I'm running this app on my Nexus android phone. Any help is appreciated.

I have the following markup:

<Alloy>
    <Tab title="POLICY">
        <Window id="PolicyWindow" class="container">
            <Button title="Take Picture" id="TakePictureButton" onClick="showCamera"/>
        </Window>
    </Tab>
</Alloy>
The showCamera function is below:
function showCamera(e) {
    Titanium.Media.showCamera({
        success : function(event) {
            var w = Alloy.createController('attach').getView();
            var img1Wrapper = Ti.UI.createScrollView({
                maxZoomScale : 4.0,
            });
 
            // called when media returned from the camera
            Ti.API.debug('Our type was: ' + event.mediaType);
            if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                var imageView = Ti.UI.createImageView({
                    width : 300,
                    height : 200,
                    top : 5,
                    image : event.media
                });
 
                img1Wrapper.add(imageView);
                w.add(img1Wrapper);
                w.open
            } 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 : true,
        allowEditing : true,
        mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO]
    });
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>