科尔多瓦3.4.0 navigator.camera.getPicture不回调的onSuccess或onFail为Android 4.3 [英] Cordova 3.4.0 navigator.camera.getPicture does not callback onSuccess or onFail for Android 4.3

查看:388
本文介绍了科尔多瓦3.4.0 navigator.camera.getPicture不回调的onSuccess或onFail为Android 4.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的科尔多瓦3.4带摄像头的插件(<一个href=\"https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md\">https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md)

I am using Cordova 3.4 with Camera Plugin (https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md)

当我打电话

navigator.camera.getPicture(onSuccess, onFail, {
        quality: 75,
        destinationType: window.Camera.DestinationType.FILE_URI,
        sourceType: window.Camera.PictureSourceType.CAMERA,
        //allowEdit: true,
        //cameraDirection: window.Camera.Direction.FRONT,
        //encodingType: window.Camera.EncodingType.JPEG,
        //targetWidth: 100,
        //targetHeight: 100,
        //popoverOptions: window.CameraPopoverOptions,
        saveToPhotoAlbum: true
    });
function onSuccess(imageData) {
    alert(imageData);
}
function onFail(message) {
    alert('Failed because: ' + message);
}

这code适用于Windows Phone的8.1,但为Android 4.3(果冻豆)不起作用。当我踏入在eclipse code,我可以看到它成功保存照片的Andr​​oid temp目录下,但不调用JavaScript的成功或失败事件的完整的,这就是为什么我不能在Android上获取的图像。

this code works for Windows Phone 8.1 but does not work for Android 4.3 (Jelly Bean). When I step into code in eclipse I can see that it successfully saves photo under android temp directory but does not call JavaScript success or fail event on complete, that's why I cannot get image on android.

我都试过的Galaxy Note 2实际设备和仿真器,并没有要求的onSuccess两个。

I both tried on Galaxy Note 2 real device and emulator and did not call onSuccess on both.

是否有任何已知问题或解决方法这个问题?

Is there any known issues or workaround for this problem?

推荐答案

如果这是行不通的,让我为您介绍这些选项。他们正在为部署在4.2.2(杰利贝恩)Android和4.4.2(奇巧)。

If this isn't working, let me suggest these options. They're working as deployed on 4.2.2 (Jellybean) android and 4.4.2 (Kitkat).

navigator.camera.getPicture(this.onPhotoDataSuccess, this.onFail, {
            quality: 50,
            destinationType: Camera.DestinationType.DATA_URL,
            sourceType: Camera.PictureSourceType.CAMERA

        });

//读取和追加DOM

//reading and appending the DOM

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

这将返回一个base64连接codeD映像。

This will return a base64 encoded image.

这篇关于科尔多瓦3.4.0 navigator.camera.getPicture不回调的onSuccess或onFail为Android 4.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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