2013-04-30 55 views
3

我正在开发一款应用程序,您可以用手机拍照并发送至社交网络。 我的应用程序是用sencha touch 2和Phonegap开发的。 当我尝试拍照时,我的应用程序重新启动,并给我一个错误'相机取消'。 我试着看console.logs但它们不会出现...错误'相机已取消' - 带有PhoneGap的应用程序Sencha

这里是我的代码:

function uploadPhoto(data){ 
       // this is where i will send the image file to server 
       //output image to screen 
        console.log(data); 
       } 
    function fail(msg){ 
        alert(msg); 
       } 
    navigator.camera.getPicture(uploadPhoto, fail, { 
        quality : 30, 
        destinationType: Camera.DestinationType.DATA_URL 
       });</i> 

回答

0

PhoneGap的哪个版本您使用的?我在这里尝试使用2.7.0,它没有问题。

+0

我试过phonegap 2.3.0,现在我已经试过2.6.0,没有成功!我会现在尝试2.7.0,如果作品... – 2013-05-02 17:43:21

+1

我试着用2.7.0而没有任何东西!我在我的手机上进行了测试,并给出了同样的错误。 – 2013-05-02 17:57:39

4

此处同样的错误。我为Android安装了cordova v2.6。

要解决它,我必须编辑AndroidManifest.xml并将DroidGap活动启动模式从“singleInstance”更改为“standard”。

+1

我已经对此有所作为,但是不起作用:'(我在这个...上有2个mounths ... fff ... uck! – 2013-06-04 14:01:57

+0

文档底部有一个部分:http://cordova.apache.org /docs/en/2.5.0/guide_cordova-webview_android.md.html#Embedding%20Cordova%20WebView%20on%20Android这个标题是“除此之外,如果您使用相机,您也需要实现这一点: “......也许这有帮助? – cat 2013-06-19 13:45:00

0

此行添加到AndroidManifest

<uses-feature android:name="android.hardware.camera.PictureCallback" /> 
1

我都快疯了这一点。

你必须非常确定你使用了哪些选项并传递给$ cordovaCamera.getPicture(options *)。例如,如果您使用saveToPhotoAlbum(true或false),则会失败,因为Android不具备此选项,所以您总是会获得“相机取消”。不要在android上使用这个配置。

希望它能帮助!

相关问题