abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

12/14/2020

How to access camera in android WebView

 if you are making hybrid apps , which works on all os(android, ios, windows)


step -1) in HTML add capture attribute .

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


step -2) go to uses permissions in mainfest.xml in android project

add below line to set uses permission 

<uses-permissions android:name="android.permission.camera" />



step -3) ask user to accept permission

webview.getSettings().setJavaScriptEnabled(true);

webview.getSettings().setDomStorageEnabled(true);

webview.getSettings().setPluginState(WebSettings.PluginState.ON);


webview.setWebChromeClient(new WebChromeClient(){

         

        @Override

        public void onPermissionRequest(final PermissionRequest request) {

            L.d("onPermissionRequest");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                 request.grant(request.getResources());

            }

        }

    });


just use this three steps and remaining is same . 


this useful when upload product, setting profile picture, attaching document.


An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...