cordova 3.4.1显示相机未定义

时间:2014-07-24 14:39:14

标签: cordova

我正在使用cordova创建一个应用程序,允许用户允许拍照,我的问题是navigator.camera变得不确定我按照http://cordova.apache.org/docs/en/3.1.0/cordova_camera_camera.md.html中的过程  我的代码是

   function TakePicture()
    {
           event.preventDefault();
        if (!navigator.camera) {
            OpenModalDialog('Alert', 'Camera API not supported', '80%', '20%');
            return;
        }
        var options = {
            quality: 50,
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: 1,      // 0:Photo Library, 1=Camera, 2=Saved Album
            encodingType: 0,     // 0=JPG 1=PNG
            saveToPhotoAlbum: true
        };

        navigator.camera.getPicture(
            function (imageData) {
                window.resolveLocalFileSystemURI(imageURI, resolveOnSuccess, fsFail);
                //$('.employee-image', this.el).attr('src', "data:image/jpeg;base64," + imageData);
                //  var image = document.getElementById('myImage');
                //   image.src = imageURI;
            },
            function () {
                OpenModalDialog('Alert', 'Error taking picture', '80%', '20%');                 
            },
            options);

        return false;

    }
      function Browse()
    {


         if (!navigator.camera) {
             OpenModalDialog('Alert', 'Camera API not supported', '80%', '20%');
            return;
        }
        navigator.camera.getPicture(onSuccess, onFail, {
            quality: 50,
            destinationType: navigator.camera.DestinationType.FILE_URI,
            sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
        });


        function onSuccess(imageData) {
            //  var image = document.getElementById('myImage');
            //   image.src = "data:image/jpeg;base64," + imageData;
        }

        function onFail(message) {
            OpenModalDialog('Alert', 'Failed because: ' + message, '80%', '20%');
        }
    }




 document.addEventListener("deviceready", onDeviceReady, false);


     function onDeviceReady() {

                       OpenModalDialog('Alert',' Camera '+navigator.camera,'80%','20%');
                    }
我检查过   在AndroidManifest和(在app / res / xml / config.xml中)

 <feature name="Camera">
        <param name="android-package" value="org.apache.cordova.CameraLauncher" />
    </feature>

一切都很好,但相机仍未定义,即使我在onDeviceReady中调用navigator.camera也试过但是没有运气,帮帮我......

0 个答案:

没有答案