Home Web View Android cannot open Camera and browse file explorer
Reply: 0

Web View Android cannot open Camera and browse file explorer

user2515
1#
user2515 Published in June 19, 2018, 2:44 pm

I am trying to capture image and browse file in a WebView, but I'm unable to access any. I have declared the permissions in the manifest but no response, also I see enable permission in app settings.

Here's permission,

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

--- Class Code --- But its not calling.

 webView_login.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            Log.i("Permission", "|> onPermissionRequest");
            getActivity().runOnUiThread(new Runnable() {
                @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void run() {
                    Log.i("Permission", "|> onPermissionRequest run");
                    request.grant(request.getResources());
                }
            });
        }
    });

Perfectly run this code, load URL

webView_login.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);


        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);

        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView wView, String url) {

            return true;
        }

        public void onReceivedError(WebView view, int errorCode,
                                    String description, String failingUrl) {


        }
    });

    webView_login.getSettings().setJavaScriptEnabled(true);
    webView_login.getSettings().setLoadWithOverviewMode(true);
    webView_login.getSettings().setUseWideViewPort(true);
    webView_login.getSettings().setAllowFileAccess(true);
    webView_login.getSettings().setAllowContentAccess(true);
    webView_login.getSettings().setAllowFileAccessFromFileURLs(true);
    webView_login.getSettings().setAllowUniversalAccessFromFileURLs(true);
    webView_login.getSettings().setDomStorageEnabled(true);

Page load, start, and finish perfectly. All things are working except Camera and browse file. Please reply if you have any idea...

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.496797 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO