Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
How to take a image shot from camera in webview android app

I have a simple web app, running in WebView, so complete android application is just one WebView and URL set to my page. In web app, I have a button that user clicks to take a shot from camera prior to continue to another part of app. All of this works just fine when in regular phone browser. However in WebView is not working.

In HTML page there is file input field, which is hidden:

<input type="file" name="fileToUpload" id="fileToUpload" onchange="receiveAShot();" accept="image/*" capture="camera" style="display:none;" />

and button which is performing action:

$(document).on("click", "#buttonId", function () {
    $("#fileToUpload").click();
})

and this works like a charm in phone web browsers (checked Chrome and Firefox).

I have set permissions to android app to

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />

and for WebView in Main activity:

WebView webView=findViewById(R.id.webview);

WebSettings settings = webView.getSettings();
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);
settings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("http://some.url.com");

I'm sure that javascript works regularly, since I was able to login (not classic form, just ajax request). But when I click button to start capture image, nothing happens at all. Any idea?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!