Cordova 3.4.0 navigator.camera.getPicture不回调onSuccess或onFail for Android 4.3 [英] Cordova 3.4.0 navigator.camera.getPicture does not callback onSuccess or onFail for Android 4.3

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

问题描述

我使用Cordova 3.4 with Camera Plugin( 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);
}

此代码适用于Windows Phone 8.1,但不适用于Android 4.3豆)。当我在eclipse中的代码,我可以看到它成功保存在android 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?

推荐答案

如果它帮助任何人,我有同样的问题。原来,我正在调用navigator.camera.cleanup()在Cordova的暂停事件的应用程序(所以它会清理资源,当应用程序发送到后台)。这里的问题是,相机发送的应用程序的背景,所以显然调用清理打破了东西。

If it helps anyone, I had this very same issue. It turned out that I was calling "navigator.camera.cleanup()" in the Cordova "pause" event of the app (so it would clean up resources when the app was sent to the background). The problem here was that the camera sends the app to the background, so apparently calling cleanup was breaking things.

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

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