PhoneGap的应用程序退出相机拍摄的图像后。 [机器人] [英] Phonegap app quits after Camera captures image. [Android]

查看:122
本文介绍了PhoneGap的应用程序退出相机拍摄的图像后。 [机器人]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个错误与PhoneGap的1.4.1。

在PhoneGap的应用程序创建重新启动拍照后后,我回到了应用程序。

下面是code我使用:

 函数capturePhoto(){
  //拍照使用设备的摄像头和图像检索为base64-CN codeD字符串
  navigator.camera.getPicture(onPhotoURISuccess,onFail,{品质:50,destinationType:Camera.DestinationType.FILE_URI});
}

功能onPhotoURISuccess(imageURI){
  //取消注释要查看的影像文件URI
  //执行console.log(imageURI);

  //获取图像处理
  //
  变种largeImage =的document.getElementById('largeImage');

  //取消隐藏图像元素
  //
  largeImage.style.display =块;

  //显示所拍摄的照片
  //内联CSS规则是用来调整图像大小
  //
  largeImage.src = imageURI;
}
 

解决方案

我是有2天了同样的问题,直到我发现那位,你应该有机会获得让你的设备在拍摄影像文件的权限。默认情况下有回图像,这样它返回null和你的应用程序崩溃的没有权限。

如果您使用的是科尔多瓦/ PhoneGap的在X code,那么你也应该建立在WWW文件夹中的Config.xml文件,并给予权限存取权限的图像文件。

 <功能名称=htt​​p://api.phonegap.com/1.0/device/>
<功能名称=htt​​p://api.phonegap.com/1.0/battery/>
<功能名称=htt​​p://api.phonegap.com/1.0/camera/>
<功能名称=htt​​p://api.phonegap.com/1.0/contacts/>
<功能名称=htt​​p://api.phonegap.com/1.0/file/>
<功能名称=htt​​p://api.phonegap.com/1.0/geolocation/>
<功能名称=htt​​p://api.phonegap.com/1.0/media/>
<功能名称=htt​​p://api.phonegap.com/1.0/network/>
<功能名称=htt​​p://api.phonegap.com/1.0/notification/>
 

如果您正在使用的Andr​​oid然后给在AndroidManifest.xml文件的权限。

您可以找到一切在这里config.xml文件: https://build.phonegap.com/docs/config-xml

I'm getting an error with Phonegap 1.4.1.

The phonegap app I create restarts after I am returned to the app after taking a picture.

Here is the code I'm using:

function capturePhoto() {
  // Take picture using device camera and retrieve image as base64-encoded string
  navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI });
}

function onPhotoURISuccess(imageURI) {
  // Uncomment to view the image file URI 
  // console.log(imageURI);

  // Get image handle
  //
  var largeImage = document.getElementById('largeImage');

  // Unhide image elements
  //
  largeImage.style.display = 'block';

  // Show the captured photo
  // The inline CSS rules are used to resize the image
  //
  largeImage.src = imageURI;
}

解决方案

I was having the same problem for 2 days until I fount that you should have access to the permission of getting the image file you took in the device. By default there is no permission of return the image so it returns null and your app crashes.

If you are using Cordova/PhoneGap in XCode then you should also create the Config.xml file in www folder and give permission to acces the image file.

<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>

If you are working on Android then give permission on the AndroidManifest.xml file.

you can find everything for the config.xml file here: https://build.phonegap.com/docs/config-xml

这篇关于PhoneGap的应用程序退出相机拍摄的图像后。 [机器人]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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