gpt4 book ai didi

android - PhoneGap navigator.camera.getPicture 不触发回调

转载 作者:行者123 更新时间:2023-11-28 17:55:01 24 4
gpt4 key购买 nike

我的 PhoneGap 应用程序中有一个简单的链接,它会触发以下方法:

        navigator.camera.getPicture(function(imageData) {
console.log('Success');
$('#image').attr('src', "data:image/jpeg;base64," + imageData);
}, function(errorMsg) {
console.log('Error');
}, {
quality: 30,
destinationType: Camera.DestinationType.DATA_URL,
correctOrientation: true
});

在 iPhone 和 iPad 上它有 70-80% 的时间工作:如果用户点击,相机打开,我拍照,相机关闭,成功方法中的 console.log() 将被触发我可以捕捉图像源。另一次什么都没有发生。将调用成功回调或错误回调。相机打开,我拍照,相机将关闭,我看到我的应用程序,但没有任何反应。我无法找出问题所在。

为了防止存储问题,我在每次单击链接时触发 navigator.camera.cleanup() 方法。但问题仍然存在。在 iPhone、iPad 和我的 Android 模拟器上。首先,我以为我的应用程序会在拍照后自动重启,但这并没有发生(如果设备就绪事件正在发生,我会生成一个 console.log)。

我不认为这是 Android 或 iOS 的问题...但我不知道。

最佳答案

确保在 onDeviceReady 中调用它

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady()
{
your code here!
}

关于android - PhoneGap navigator.camera.getPicture 不触发回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12920289/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com