PhoneGap的:相机在Android的奇巧不工作 [英] Phonegap : Camera not working in android kitkat

查看:410
本文介绍了PhoneGap的:相机在Android的奇巧不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android的一个App的相机应用。我使用添加相机科尔多瓦插件

I am developing an App in Android for camera application. I add the camera using cordova plugin

config.xml中

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

code采取图片

code for taking Picture

 function snapPicture () {
    navigator.camera.getPicture (onSuccess, onFail, 
        { quality: 100,  
          sourceType: navigator.camera.PictureSourceType.CAMERA,
          mediaType: navigator.camera.MediaType.PICTURE,
          destinationType: destinationType.FILE_URI,
          encodingType: navigator.camera.EncodingType.JPEG,
          correctOrientation: false,
          saveToPhotoAlbum: true
         });


    //A callback function when snapping picture is success.
    function onSuccess (imageData) {
        var image = document.getElementById ('picture');
        alert("path : "+imageData);
        image.src =  imageData;
    }

    //A callback function when snapping picture is fail.
    function onFail (message) {
        alert ('Error occured: ' + message);
    }
}

在code是所有Android版本做工精细期待的Andr​​oid奇巧。在奇巧我得到的响应是错误捕获图片

可以在任何告诉我什么是奇巧问题
在此先感谢...!

can any tell me what is the issue in Kitkat Thanks in Advance ...!

推荐答案

您的code里面犯了一个错误。 destinationType:destinationType.FILE_URI,将不起作用。更改行 destinationType:Camera.DestinationType.FILE_URI,代替,它会运行。这是你的完整的工作code:

You made a mistake inside your code. destinationType: destinationType.FILE_URI, will not work. Change that line to destinationType: Camera.DestinationType.FILE_URI, instead and it'll run. Here's your full working code:

function snapPicture() {
        navigator.camera.getPicture(onSuccess, onFail, { quality: 100,
             sourceType: navigator.camera.PictureSourceType.CAMERA,
             mediaType: navigator.camera.MediaType.PICTURE,
             destinationType: Camera.DestinationType.FILE_URI,
             encodingType: navigator.camera.EncodingType.JPEG,
             correctOrientation: false,
             saveToPhotoAlbum: true
             })


             //A callback function when snapping picture is success.
             function onSuccess (imageData) {
                 var image = document.getElementById ('picture');
                 alert("path : "+imageData);
                 image.src =  imageData;
             }

             //A callback function when snapping picture is fail.
             function onFail (message) {
                 alert ('Error occured: ' + message);
             }
    }

我建议你使用 GapDebug 来调试应用程序。

这篇关于PhoneGap的:相机在Android的奇巧不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆