cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

Bug: input capture="camera" doesn't open camera

Open Aarbel opened this issue 6 years ago • 5 comments

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

When clicking on this input, it doesn't open the camera of android device, it opens files browser instead.

Didn't found a way to fix it properly with all i read on stackoverflow and github.

Anyone has a simple solution ?

Aarbel avatar Feb 10 '20 09:02 Aarbel

cf https://github.com/apache/cordova-plugin-camera/issues/489 and https://github.com/apache/cordova-android/issues/816 which are not exactly about camera capture, but default displayed browser, so different issues.

Aarbel avatar Feb 10 '20 09:02 Aarbel

A workaround would be to use the cordova-plugin-camera APIs, although with this route, you'd probably want to build your own custom button instead of using the browser's <input> tag.

I believe this doesn't work because most of the input file attribute the native app actually needs to intercept and handle it explicitly. It's not "automatic" like the chrome browser. This could be a feature request, but there are some hurdles to jump through. Namely the requirement for apps to declare what features they use, including if they use the camera feature, which is something that the cordova-plugin-camera already does... and adding that into the core library is not really feasible imo.

breautek avatar Jun 13 '20 03:06 breautek

@Aarbel found solution?

WuglyakBolgoink avatar Nov 23 '20 13:11 WuglyakBolgoink

@WuglyakBolgoink yes i use the navigator.mediaDevices.getUserMedia API. It's not perfect, but it makes the job if you parse the medias, and select the one with "rear' and "back" in their names to get the device back camera.(in more details: navigator.mediaDevices API has an "environment" preference setting to select the back camera, but doesn't work well to select the right rear camera on all the devices (for example Microsoft Surface Devices), so it's necessary to list de media Devices and select the right ones you want.

Aarbel avatar Nov 23 '20 16:11 Aarbel

Did anyone find a solution for this yet?

shailen-naidoo avatar Jan 19 '22 05:01 shailen-naidoo