如何从移动浏览器直接访问移动设备的硬件功能

发布于 2024-11-26 00:17:39 字数 319 浏览 7 评论 0原文

我们正在开发手机网络浏览器应用程序,我正在尝试找到一种方法,可以访问相机并拍照,然后将其上传到互联网。但到目前为止,我建议是使用phonegap 并创建本机应用程序。 Phonegap 很好,但它不是我想要的,因为我的客户想要设计表单,而这些 html 表单以某种方式能够触发相机并拍照并将其上传到服务器。您认为为每个平台开发原生 API 并通过网络浏览器访问其功能是否可能?你的建议是什么?

(注意:我的客户只想要可以在移动网络浏览器上运行的应用程序,没有本机应用程序可以在 I-Phone、Windows Mobile、Blackberry 和 Android 上运行)

非常感谢...

We are developing web browser application for mobile phones and I am trying to figure out a way that I can gain access to the camera and take a photo and then upload it to the internet. But so far what I was suggested is to use phonegap and create native application. Phonegap is fine but it is not what I am looking for because my client wants to design forms and these html forms somehow will be able to trigger the camera and take photo and upload it to a server. Do you think developing a native API for every platform and having access to its functions from the web browsers is possible? What your suggestion would be?

(Note: My customer only want application that can run on mobile web browsers no native application runs on I-Phone, windows mobile, Blackberry and Android)

Thanks a lot...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

太阳哥哥 2024-12-03 00:17:39

Web 应用程序(未按照 Kumar 详细信息封装在本机代码中)无法访问所有设备硬件和传感器。 iOS 和 Android 上提供位置支持,但仅在 Android 上提供相机访问(通过 JavaScript)。同样,设备运动 API 在 Android 上无法访问,但在 iOS 上可以访问。

正如您所看到的,支持是粗略的,如果您确实希望使用这些功能,那么您最好(并且在许多情况下,现实地考虑)为您打算支持的每个平台编写本机应用程序。

HTML5 尚未达到可以取代原生应用程序的程度。它可以完成本机应用程序可以完成的一些操作,但即使如此,性能也不是最优的。目前,本机应用程序可能更加困难和耗时,但它们是必要的。

Web apps (not wrapped in native code as Kumar details) cannot access all device hardware and sensors. Location support is available on iOS and Android, but camera access is only available on Android (via JavaScript). Similarly, device motion APIs are not accessible on Android, but are on iOS.

As you can see, support is sketchy and if you are truly looking to use such features, you are better off (and in many cases, realistically looking at) writing native apps for each platform you intend to support.

HTML5 is not yet at the point where it can replace native apps. It can do some of the things that native apps can, but even then performance is suboptimal. Currently, native apps may be more difficult and time-consuming, but they are necessary.

仅一夜美梦 2024-12-03 00:17:39

从 javascript 调用 android 原生 API嵌入式WebView的功能

使用JS调用Java代码,Java代码将依次调用Camera API或您正在寻找的任何其他内容。

Calling android native APIs from javascript functions of embedded WebView

Use JS to call Java code which will in-turn call the Camera API or whatever else you are looking for.

秋叶绚丽 2024-12-03 00:17:39

在 iPhone 上不可能做到这一点,唯一已知的访问相机的方法是通过 Cocoa 层。

It's not going to be possible to do it on iPhone, the only known way of accessing the camera is through the Cocoa layer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文