在没有使用科尔多瓦相机的情况下,在android上的cordova应用程序中选择相机 [英] Choose camera in file upload in cordova application on android without using cordova camera

查看:133
本文介绍了在没有使用科尔多瓦相机的情况下,在android上的cordova应用程序中选择相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我做了一个科尔多瓦应用程序,我添加了android平台,并用一个imput字段创建了一个简单的html

 < input type =filecapture =cameraaccept =image / *id =takePictureField> 

我已经添加了

 <使用权限android:name =android.permission.CAMERA/> 
< uses-feature android:name =android.hardware.cameraandroid:required =false/>
< uses-feature android:name =android.hardware.camera.autofocus/>
< feature name =http://api.phonegap.com/1.0/camera/>

添加到清单文件中。



但当我按下按钮时,我无法选择用相机拍摄新照片。是否有任何许可我想念,或者其他任何??

我不能使用cordova拍照功能,它必须在纯html中完成。

解决方案

经过一些Google搜索,我可以得出这样的结论:
$ b $ p

在移动浏览器中似乎仍然存在一些问题。看看这个链接。摘录说:


实际上,目前的实现似乎并不依赖于 capture 属性,但仅限于类型接受属性:浏览器显示一个对话框,其中用户可以选择文件的获取位置,并且不考虑capture属性。例如,iOS Safari依赖于图像和视频(不是音频)的接受属性(不捕获)。即使您不使用接受属性,浏览器也会让您选择拍照或录像和选择现有的


所以看起来像capture属性不会产生任何影响。

另外,建议你看看这个 SO贴子了解更多信息工作。希望能帮助到你。干杯。

更新:在downvoting之后,我对这个问题进一步深入探讨。大部分搜索都没有成功,因为此问题的最佳解决方案是使用Cordova相机插件。最后偶然发现了这个 SO贴子<一个>这是完全重复的这个问题。用户能够解决这个问题(尽管使用人行横道Web视图)。这篇文章的答案在这里已经被@Fabio提及。但不是仅仅为了包含权限而添加插件,您可以使用 cordova-custom-plugin 添加所需的权限。根据@ jcesarmobile的评论(谁是科尔多瓦专家)在没有人行横道web视图插件的帖子中,输入类型只在iOS上适用,而不适用于Android。因此,使用相机插件是使其无需使用人行横道插件即可工作的唯一方法。希望它有帮助。

更新2:更新后的问题后,我挖得更深一点为解决这个问题。但是现在我可以确保Android Webview仍未解决此问题。看起来这不是科尔多瓦问题,而是Chromium网络视图的问题。



有关详细信息,请您在Apache Cordova Issue Tracker中查看这些问题:



到目前为止,这两个问题都没有解决。所以我确信现在,除非你使用科尔多瓦相机插件,否则你不能在Android上工作。希望你同意我的看法并接受决议。干杯


So i made a cordova app, i added android platform and made a simple html with an imput field

<input type="file" capture="camera" accept="image/*" id="takePictureField">

I have added

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<feature name="http://api.phonegap.com/1.0/camera" />

to the manifest file.

but when i press the button I cannot choose to take a new picture with the camera. are there any permission i miss, or anything else ??

I cannot use the cordova take picture functions, it has to be done in pure html.

解决方案

After a bit of Googling, this is what I could conclude:

Media capture in mobile browsers still seems to have some issues. Check out this link. The excerpt says:

Actually, it seems that current implementations don’t rely on the capture attribute at all, but only on the type and accept attributes: the browser displays a dialog box in which the user can choose where the file has to be taken, and the capture attribute is not taken into consideration. For example, iOS Safari relies on the accept attribute (not capture) for images and videos (not audio). Even if you don’t use the accept attribute, the browser will let you choose between "Take Photo or Video" and "Choose Existing"

So looks like capture attribute does not make any impact.

Also, suggest you look at this SO post for more info on making this work. Hope it helps. Cheers.

UPDATE: After downvoting, I dig further deep regarding the issue. Most of the searches resulted in no success as the optimum solution for this issue is to use Cordova camera plugin. Finally stumbled on this SO post which is exactly duplicate of this question. The user was able to resolve the issue (using crosswalk web view, though). The answer in that post is mentioned here already by @Fabio. But instead of adding the plugin just for including the permissions, you can make use of cordova-custom-plugin to add the required permissions.

Also as per @jcesarmobile's comment (who is a Cordova expert) in the post without crosswalk web view plugin, input type works fine only on iOS and not on Android. So using camera plugin is the only way to make it work without using crosswalk plugin.Hopefully, it helps.

UPDATE 2: After the updated question, I dug bit more deep for the resolution of this issue. But now I can assure that this issue is still not resolved for Android Webview. Looks like it is not a Cordova issue but issue with Chromium web view.

For detailed info, request you to please look at these issues in Apache Cordova Issue Tracker:

Both these issues are unresolved till date. So I m sure that for now, you cannot make it work on Android unless you use Cordova camera plugin. Hope you agree with me and accept the resolution. Cheers

这篇关于在没有使用科尔多瓦相机的情况下,在android上的cordova应用程序中选择相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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