gpt4 book ai didi

android - 相机拍摄图像后,Phonegap 应用程序退出。 [安卓]

转载 作者:IT老高 更新时间:2023-10-28 23:34:52 30 4
gpt4 key购买 nike

Phonegap 1.4.1 出现错误。

我创建的phonegap应用在我拍照后返回应用后重启。

这是我正在使用的代码:

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;
}

最佳答案

我在 2 天内遇到同样的问题,直到我发现您应该有权访问获取您在设备中拍摄的图像文件的权限。默认情况下没有返回图片的权限,所以它返回 null 并且你的应用程序崩溃。

如果您在 XCode 中使用 Cordova/PhoneGap,那么您还应该在 www 文件夹中创建 Config.xml 文件并授予访问图像文件的权限。

<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"/>

如果您使用的是 Android,请授予 AndroidManifest.xml 文件的权限。

您可以在此处找到 config.xml 文件的所有内容: https://build.phonegap.com/docs/config-xml

关于android - 相机拍摄图像后,Phonegap 应用程序退出。 [安卓],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9303701/

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