Android 森查+;Phonegap问题(navigator.camera.getPicture函数崩溃应用程序)

Android 森查+;Phonegap问题(navigator.camera.getPicture函数崩溃应用程序),android,cordova,sencha-touch,Android,Cordova,Sencha Touch,我在sencha touch框架中新编程,我在一个应用程序(android)中工作,它必须拍摄一张照片,然后在另一个视图中显示,但是照片拍摄没有问题,但是一旦我拍摄了照片,应用程序崩溃,它甚至不会调用失败事件。我正在使用cordova的navigator.camera.getPicture函数拍照。谁能告诉我,我错过了什么?我是这样做的,你可以试试 config: { cls:'cameraimageoverlay', items: [

我在sencha touch框架中新编程,我在一个应用程序(android)中工作,它必须拍摄一张照片,然后在另一个视图中显示,但是照片拍摄没有问题,但是一旦我拍摄了照片,应用程序崩溃,它甚至不会调用失败事件。我正在使用cordova的navigator.camera.getPicture函数拍照。谁能告诉我,我错过了什么?

我是这样做的,你可以试试

config: {

        cls:'cameraimageoverlay',
        items: [    
            {
                xtype: 'button',
                ui: 'confirm',
                iconCls: 'confirm',
                id:'devicecapturephoto',
                text: 'Take Photo',
                margin: '10 40',
                width: '72%',
                height: 36
            }

        ],
        listeners:[
            {
                fn: 'capturePhoto',
                event: 'tap',
                delegate: '#devicecapturephoto'
            }
        ]
    }
capturePhoto功能

 capturePhoto:function() {
    // Take picture using device camera and retrieve image as base64-encoded string
        try{


            var pictureSource;   // picture source
            var destinationType; // sets the format of returned value
            document.addEventListener("deviceready", onDeviceReady, false);
            function onDeviceReady () {
              //  alert('device ready');
                pictureSource = navigator.camera.PictureSourceType;
                destinationType = navigator.camera.DestinationType;
            }

            function onPhotoDataSuccess(imageData) {

                var smallImage = document.getElementById('smallImage');
                smallImage.style.display = 'block';
                smallImage.src = "data:image/jpeg;base64," + imageData;
            }

            // Called when a photo is successfully retrieved
            //
            function onPhotoURISuccess(imageURI) {
                // Uncomment to view the image file URI
                // console.log(imageURI);

                // Get image handle
                //
                var largeImage = document.getElementById('largeImage');

                // Unhide image elements
                //
                largeImage.style.display = 'block';

                // Show the captured photo
                // The in-line CSS rules are used to resize the image
                //
                largeImage.src = imageURI;
            }

            // A button will call this function
            //
                // Take picture using device camera and retrieve image as base64-encoded string
                navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, correctOrientation: true,
                    destinationType: destinationType.DATA_URL });


            // A button will call this function
            //
            function capturePhotoEdit() {
                // Take picture using device camera, allow edit, and retrieve image as base64-encoded string
                navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
                    destinationType: destinationType.DATA_URL });
            }

            // A button will call this function
            //
            function getPhoto(source) {
                // Retrieve image file location from specified source
                navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
                    destinationType: destinationType.FILE_URI,
                    sourceType: source });
            }

            // Called if something bad happens.
            //
            function onFail(message) {
                alert('Failed because: ' + message);
            }
        }
        catch(err){
           // alert(err);
        }
    }
你可以参考