Android的PhoneGap的2.2错误COM pressing图像 [英] Android Phonegap 2.2 Error compressing image

查看:216
本文介绍了Android的PhoneGap的2.2错误COM pressing图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用PhoneGap的2.2(科尔多瓦-2.2.0.js)的应用程序。我试图捕捉图像。当我preSS上传按钮,相机打开时,我拍摄照片,然后出现两种选择,放弃和保存屏幕。如果我点击保存,应用程序回归到我原来的屏幕,我收到错误的错误COM pressing形象。

I am developing an app using phonegap 2.2 (cordova-2.2.0.js). I'm trying to capture an image. When i press the button for upload, the camera opens, i take the picture, and then a screen appears with two options, discard and save. If i click save , the app return to my original screen and i receive the error Error compressing image.

我以前从PhoneGap的文档的code:

I used the code from the phonegap docs:

http://docs.phonegap.com/en/ 2.2.0 / cordova_camera_camera.md.html#cameraOptions

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
alert("device ready");

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = "data:image/jpeg;base64," + imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}
var options = {
        quality : 100,
        destinationType : Camera.DestinationType.DATA_URL,
        sourceType : Camera.PictureSourceType.CAMERA, 
        encodingType: Camera.EncodingType.JPEG,
        saveToPhotoAlbum: true

}
$("#takePicture").click(function(){
    navigator.camera.getPicture(onSuccess, onFail, options); 

})

}

我试着设置destinationType的选择:Camera.DestinationType.FILE_URI,

I tried setting the option of destinationType : Camera.DestinationType.FILE_URI,

和错误修改错误捕获图像和logcat的显示器

and the error changes to Error capturing image and the logcat displays

十二月12日至11日:23:13.965:W / System.err的(2419):java.io.FileNotFoundException:/mnt/sdcard/Android/data/ro.iss.my.package/cache/.Pic.jpg :打开失败:ENOENT(没有这样的文件或目录)

12-11 12:23:13.965: W/System.err(2419): java.io.FileNotFoundException: /mnt/sdcard/Android/data/ro.iss.my.package/cache/.Pic.jpg: open failed: ENOENT (No such file or directory)

在第一种情况下的logcat不显示任何错误。

In the first case the logcat does not show any errors .

12-11 12:27:13.990: D/DroidGap(3618): Paused the application!
12-11 12:27:13.990: D/CordovaWebView(3618): Handle the pause
12-11 12:27:14.930: W/IInputConnectionWrapper(3618): showStatusIcon on inactive InputConnection
12-11 12:27:22.105: I/System.out(3618): Not a DRM File, opening notmally
12-11 12:27:22.160: D/dalvikvm(3618): GC_EXPLICIT freed 7823K, 38% free 13168K/21191K, paused 3ms+2ms
12-11 12:27:22.160: W/CursorWrapperInner(3618): Cursor finalized without prior close()
12-11 12:27:22.160: D/DroidGap(3618): Resuming the App
12-11 12:27:22.195: W/CursorWrapperInner(3618): Cursor finalized without prior close()
12-11 12:27:22.195: W/CursorWrapperInner(3618): Cursor finalized without prior close()

我在Android 4.0.3两个设备上测试此。

I'm testing this on android 4.0.3 on two devices.

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

您从您的权限列表中缺少WRITE_EXTERNAL_STORAG​​E。没有它,应用程序将无法写入JPG文件。

You are missing WRITE_EXTERNAL_STORAGE from your list of permissions. Without it the app will be unable to write the jpg file.

这篇关于Android的PhoneGap的2.2错误COM pressing图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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