PhoneGap的摄像头API不火SuccessCallBack mthod上附加caprured形象摄像头、形象、API、PhoneGap

2023-09-04 23:31:06 作者:咬遍天下无敌手

我是用PhoneGap的API来捕捉图像。

I am using the Phonegap API to capture an image.

在我拍摄照片并将其安装在我的成功回调方法没有被调用。

Once i take the picture and attach it my success call back method is not called .

下面是如何我已经实现了。

Here is how i have implemented it.

在我添加了Phonegap.jar文件也已将此添加到构建路径的库。

和我的主要活动扩展了DroidGap类我指定 super.loadUrl( http://test.someU.com/Android/testandroid.html); I have added the Phonegap.jar file to the libs also added this to the build path .

And on my Main Activity which extends the DroidGap class i specify super.loadUrl("http://test.someU.com/Android/testandroid.html");

本页面testandroid.html包含引用PhoneGap.js脚本文件也是另一个JS称为主。

This page testandroid.html contains a reference to the PhoneGap.js script file also another js called the main .

在单击相机按钮,相机打开,但在重视所拍摄图像的成功回调方法是不叫的。

On click of the camera button the camera opens but on attach of the captured image the success callback method is not called .

function dump_pic(data) {
    alert(data);        
}

function fail(msg) {
    alert(msg);
}

function show_pic() {
    navigator.camera.getPicture(dump_pic, fail, { quality: 50 });
}

在全成装上拍摄的照片中有调用dump_pic与它的base64数据被惊动什么也没有发生。

On successfull attach of the taken picture it has to call the dump_pic with it base64 data being alerted nothing happens.

现在,如果我执行相同,但略有差异 这是我下的资产文件夹有一个WWW文件夹下,我有一个文件,说的index.html和C的唯一区别同样高于$ C $这里是super.loadUrl 方法改变super.loadUrl(文件:///android_asset/www/index.html);为PhoneGap的例子做它在这种情况下,一切都只是工作正常,也称为T他成功的回调方法也发生故障时故障的方法。

Now , If i implement the same but with slight differences That is i under the assets folder have a www folder under which i have a file say index.html and the same above code the only difference here is the super.loadUrl method changes to super.loadUrl("file:///android_asset/www/index.html"); as the phonegap example does it in that case everything just works fine it called t he success call back method also the failure method in case of a failure .

我已经实现的应用程序是一个Web应用程序,并具有通过第一种方法来工作的一些方式。任何想法,如何打通这一点。感谢您的帮助是很大的。

The application i have implemented is a web app and has to work some how by the first method . Any idea as to how to get through this . Thanks any help is greatly

推荐答案

这是出于安全原因的PhoneGap应用程序正确的行为。

this is correct behaviour of a phonegap app for security reasons.

如果你可以从web视图加载的网页访问摄像头,这将打开很多可能的安全隐患。

If you could access the camera from a webpage loaded in the Webview this would open a lot of possible security hazards.

您必须从本地index.html文件加载摄像头。

You have to load the camera from the local index.html file.

您可以在如何部署您的应用程序在手机上UND和使用市场更新一起来看看。

Take a look in how to deploy your app on the phone und and use market place for updates.