Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda