1

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...

Pinchy
  • 1,506
  • 8
  • 28
  • 49

3 Answers3

6

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.

jlengstorf
  • 447
  • 1
  • 5
  • 10
Benjamin Mayo
  • 6,649
  • 2
  • 26
  • 25
  • Hi Benjamin, can you refer this link and if possible answer my question please.. http://stackoverflow.com/questions/34396599/how-to-fetch-serial-number-from-android-mobile-browser-using-java-scripting-whic/34406907#34406907 – harikrishnan Dec 22 '15 at 05:18
0

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.

Community
  • 1
  • 1
Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
  • What about I-phone and Windows Mobile 7 – Pinchy Jul 21 '11 at 19:26
  • For iPhone, I am sure you can do that, I am not sure about Windows 7 – Kumar Bibek Jul 21 '11 at 19:28
  • 1
    Please note that "embedded WebView" implies a native application for the webview to be embedded in. Technically that is true of any web browser on an android device - the real question is if there is an existing web browser which exposes the camera in this manner (hopefully after per-site user authorization), or if the client is going to have to come up with their own native application - which would basically be a "web browser" consisting of the built in webview functionality plus the native api glue in the above link, probably limited to use with their particular website. – Chris Stratton Jul 21 '11 at 19:48
  • As of now, especially for Android, you can't use just a WebView to do everything. I am quite sure same is the case with iPhone as well. So, there needs to be a "native api glue" for each platform. Even so, you just can't create only the HTML, CSS and JS which would directly run on all the platforms. You will eventually, have to package it up differently for different platforms. – Kumar Bibek Jul 21 '11 at 19:55
0

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.

spamboy
  • 32
  • 5