phonegap 相机 API 不会在附加捕获的图像时触发 SuccessCallBack 方法
我正在使用 Phonegap API 来捕获图像。
一旦我拍照并附加它,我的成功回调方法就不会被调用。
这是我的实现方式。
- 我已将 Phonegap.jar 文件添加到库中,并将其添加到构建路径中。
在我的主要活动中,它扩展了我指定的 DroidGap 类 super.loadUrl("http://test.someU.com/Android/testandroid.html");
此页面 testandroid.html 包含对 PhoneGap.js 脚本文件以及另一个名为 main 的 js 的引用。
单击相机按钮时,相机将打开,但在附加捕获的图像时,不会调用成功回调方法。
函数 dump_pic(数据) { 警报(数据); } 函数失败(消息){ 警报(消息); } 函数 show_pic() { navigator.camera.getPicture(dump_pic, 失败, { 质量: 50 }); }
成功附加所拍摄的图片后,它必须调用 dump_pic 并使用其 Base64 数据来警告没有任何反应。
现在,如果我实现相同但略有不同 也就是说,我在 asset 文件夹下有一个 www 文件夹,在该文件夹下有一个文件 index.html 和上面的代码相同,这里唯一的区别是 super.loadUrl 方法更改为 super.loadUrl("file:///android_asset/www/index.html");正如phonegap示例中所做的那样,在这种情况下一切正常,它称为成功回调方法,也称为失败情况下的失败方法。
我实现的应用程序是一个网络应用程序,必须通过第一种方法来工作。关于如何度过这个难关的任何想法。非常感谢任何帮助
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.
- 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");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 }); }
On successfull attach of the taken picture it has to call the dump_pic with it base64 data being alerted nothing happens.
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 .
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于安全原因,这是phonegap应用程序的正确行为。
如果您可以从 Webview 中加载的网页访问摄像头,这将带来许多可能的安全隐患。
您必须从本地index.html 文件加载相机。
了解如何在手机上部署应用程序并使用市场进行更新。
this is correct behaviour of a phonegap app for security reasons.
If you could access the camera from a webpage loaded in the Webview this would open a lot of possible security hazards.
You have to load the camera from the local index.html file.
Take a look in how to deploy your app on the phone und and use market place for updates.