简体   繁体   English

错误:使用navigator.camera.getPicture()时出现“不允许加载本地资源”

[英]Error: “Not allowed to load local resource” when using navigator.camera.getPicture()

I'm using Corodva 2.3.0 and an Android 2.3.3 virtual device. 我正在使用Corodva 2.3.0和Android 2.3.3虚拟设备。 In my Cordova enabled app I am trying to take a picture and then have that picture display on the page. 在启用了Cordova的应用程序中,我试图拍照,然后在页面上显示该图片。 In my "Take Picture" button I am running the following code: 在“拍摄照片”按钮中,我正在运行以下代码:

function takePicture()
{
    navigator.camera.getPicture(displayPictureURI, showError, {
        quality: 50, 
        destinationType: Camera.DestinationType.FILE_URI 
    });
}

function displayPictureURI(imageURI)
{
    var imagePanel = document.getElementById('imagePanel').style.display = "";
    document.getElementById("image").src = imageURI;
}

function showError(fail)
{
    alert(fail);
}

The camera opens, I take a picture, and the app re-opens, but the picture is never displayed. 相机打开,我拍照,然后重新打开该应用程序,但从不显示照片。 In the log I get the following error: "Not allowed to load local resource: file:///mnt/sdcard/Android/data/org.apache.cordova.example/cache/1359468575251.jpg at :0" 在日志中,我收到以下错误:“不允许加载本地资源:file:///mnt/sdcard/Android/data/org.apache.cordova.example/cache/1359468575251.jpg在:0”

I'm not sure what I am doing wrong here. 我不确定我在做什么错。 I have the "WRITE_EXTERNAL_STORAGE" permission setup in the manifest. 我在清单中设置了“ WRITE_EXTERNAL_STORAGE”权限。 Any help is appreciated. 任何帮助表示赞赏。

Isn't really a proper solution, but I have found that if I use an earlier version of Phonegap, this issue doesn't occur. 确实不是一个适当的解决方案,但是我发现如果使用早期版本的Phonegap,就不会发生此问题。 It seems 1.7.0 works. 看来1.7.0可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 画廊错误中的navigator.camera.getPicture错误“无法创建位图” - navigator.camera.getPicture from the gallery error “Unable to create bitmap” navigator.camera.getPicture无法正常工作 - navigator.camera.getPicture not working properly cordova navigator.camera.getPicture 在 android 中不起作用 - cordova navigator.camera.getPicture not working in android navigator.camera.getPicture在android中不起作用 - navigator.camera.getPicture not working in android 为什么我不能在Android应用中使用Cordova 2.7.0触发navigator.camera.getPicture? - Why can't I trigger navigator.camera.getPicture using Cordova 2.7.0 in my Android app? PhoneGap navigator.camera.getPicture不触发回调 - PhoneGap navigator.camera.getPicture don't trigger Callback navigator.camera.getPicture不打开设备的默认相机应用程序 - navigator.camera.getPicture dont opens the device's default camera application Cordova navigator.camera.getPicture在Android 4.4 KitKat上以意外格式返回FILE_URI - Cordova navigator.camera.getPicture returns FILE_URI in unexpected format on Android 4.4 KitKat from gallery ionic navigator.camera.getPicture不会从PHOTOLIBRARY返回图像 - ionic navigator.camera.getPicture won't return image from PHOTOLIBRARY navigator.camera.getPicture不会调用成功回调 - 离子框架 - cordova - navigator.camera.getPicture doesn’t call success callback - ionic framework - cordova
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM