I have a mobile website that allows users to upload photos using the file input type (Browse button). If possible, I would like to launch the Camera App of an Android device on click of the Browse button or any other HTML button. Is this possible?
I read this similar post but in their example they are asking how to register the Camera App as Intent Receiver for uploading images. Similar to that, I just want to launch the Camera App in the same way the Android browser picks up on Phone Number and Addresses.
On Android devices, you can access the camera from the Browser widget. The feature is available on devices with Android OS 5.0 and later.
Thankfully, it's very simple, HTML5 has a useful element which allows taking a picture from a mobile device. If the user clicks into the input field they will be prompted to use their camera on the site.
The capture attribute is supported on the file input type. The capture attribute takes as its value a string that specifies which camera to use for capture of image or video data, if the accept attribute indicates that the input should be of one of those types. The user-facing camera and/or microphone should be used.
Android 7.0 Nougat (API level 24) introduced the native camera API, which finally allowed fine-grained control of camera directly from C++. The new API allows you to access image data directly in C, without the need to pass them from Java. Therefore, there might be some (small) performance gain.
Android 3.0 Honeycomb added Device API support. Google I/O 2011 presentation shows an example on slide 30:
<input type="file" accept="image/*;capture=camera">
It also points to a test site that not surprisingly does not do much on my Froyo phone.
Anybody with a tablet tried it and can tell us what it does and does not do?
4.0 Icecream Sandwich was announced. Code drop may not happen for several months or longer and actual devices may show in the market around Christmas. As to Icecream on current generation of Froyo / Gingerbread phones, official ODM/carrier 4.0 releases will never happen? I'd love to be proved wrong on this. Any word from custom ROMs community?
I tried this:
<input type="file" accept="image/*" capture="camera" />
from here: https://coderwall.com/p/epwmoa
With my Galaxy S2 phone (on Chrome).
It's working and open directly the camera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With