如何使用PhoneGap的-2.9.0的相机和存储在Android设备? [英] how to use phonegap-2.9.0 camera and store in android device?

查看:148
本文介绍了如何使用PhoneGap的-2.9.0的相机和存储在Android设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我太傻了,这么多东西,我试过的图片并保存到我的本地存储,但我一直在检查我的画廊(一直以为画廊会扫描所有的图像),但不知何故,它不是我的画廊所以我一直想上的形象并没有保存

我使用的PhoneGap 2.9.0,并与照相机API播放。该PhoneGap的文档,甚至提供完整的HTML例子你可以复制并粘贴code到www文件夹并部署和相机完美的作品只是它不会采取保存到本地/ SD存储图像。我试图找出如何与一直在努力了,而能有人给我一个忙吗?

I'm using phonegap 2.9.0 and playing with the camera API. The phonegap documentation even provided a full html example which you can just copy and paste the code into the www folder and deploy and camera works perfectly just that it wouldn't save the image taken into the local/sd storage. I'm trying to figure out how and been trying for a while can someone give me a hand?

我做了一些研究之前,我张贴了这个问题。
我发现一个帖子:

I did do some research before I post this question. I did find a post:

<一个href=\"http://stackoverflow.com/questions/14928202/save-image-in-local-storage-phonegap/16648829#16648829\">Save在本地存储的PhoneGap图片

但我试过code那里,不知它没有为我工作。
我还搜查他们的一些网站和岗位以及大量刚才提到的增加saveToPhotoAlbum:这是在PhoneGap的文件中提到,我尝试它没有在所有的工作。

but I tried the code there and somehow it didn't work for me. I also searched a few sites and posts and lots of them just mentioned adding saveToPhotoAlbum: true which was mentioned in the phonegap documentation and I tried which didn't work at all..

我通过PhoneGap的2.9.0文档望去,只见权限,所以我相信我需要添加这些codeS太多,所​​以我做...

I looked through the phonegap 2.9.0 documentation, and saw permissions so I believe I need to add those codes too so I did...

在config.xml中我加了

in config.xml I added

&LT;插件名称=镜头值=org.apache.cordova.CameraLauncher/&GT;

在AndroidManifest我添加

in AndroidManifest I added

&LT;使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/&GT;

和index.html中我只是用充满例子的PhoneGap。 2.9.0提供。
我认为这是太一定要在这里贴,但我相信这是我需要添加的东西到code ..

and in index.html I just used the full example which phonegap. 2.9.0 provided. I think it's too must to paste it here but I believe this is where I need to add something into the code..

// A button will call this function
//
function capturePhoto() {
  // Take picture using device camera and retrieve image as base64-encoded string
  navigator.camera.getPicture(onPhotoDataSuccess, onFail,{ quality: 50,
    destinationType: destinationType.DATA_URL, saveToPhotoAlbum: true });
}

我想加入 saveToPhotoAlbum:真正的的工作,但似乎并不像它的工作原理虽然

I thought by adding saveToPhotoAlbum: true would work but doesn't seem like it works though.

有人可以给我一个忙吗?文档看起来容易,但变得沮丧,当无法弄清楚什么是错的(

Can someone give me a hand? The documentation looks easy but gets frustrated when can't figure out what's wrong (:

推荐答案

更改此

destinationType: Camera.DestinationType.DATA_URL

destinationType: Camera.DestinationType.FILE_URI

它会回报你的imageuri,为了得到你可以在PhoneGap的使用文件系统API的确切位置

It will return you the imageuri,For getting the exact location you can make use of filesystem api in phonegap

window.resolveLocalFileSystemURI(imageURI, resolveOnSuccess, fsFail);
function resolveOnSuccess(entry) {
var fileuri = entry.toURL();
//console.log(fileuri);
}

这篇关于如何使用PhoneGap的-2.9.0的相机和存储在Android设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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