• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Webapp opening stock camera

paulb72

Lurker
Apr 26, 2022
1
1
A shot in the dark here, hope a developer can help. I am helping one of our developers who has a little trouble communicating (I am not a developer). We want our web app to open the stock Front camera, but it opens the rear camera instead, but not on all devices, some older devices running Android 9 open the front camera. I suspect this has something to do with the changes in Android 10, but I'm looking for a work around.
Here is the code snippet of how he is opening the camera, please help me get the front camera to open across multiple android devices (mostly using Chrome browser for the web app). Any help is GREATLY appreciated.

var stockCamElem = document.createElement("input");

stockCamElem.id = 'stock_camera_capture';
stockCamElem.setAttribute("type", 'file');
stockCamElem.setAttribute("accept", "image/*");
stockCamElem.setAttribute("capture", "environment");
// set onchange event to call callback when user has selected file

$("#mainContainer").append(stockCamElem);
$("#stock_camera_capture").hide();
$("#stock_camera_capture").click();
$("#stock_camera_capture").change(function() {
readIdDocFileUploadUrl($("#stock_camera_capture")[0]);
});
 
  • Like
Reactions: mikedt

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones