0

I have a Hybrid App with a Web View. Unfortunately, the Web View doesn't reproduce the same features of the default one. I have the following code:

 webView.webViewClient = WebViewClient()

If I do that, not all JavaScript and HTML 5 code is executed in the right way even with the following line:

webView.settings.javaScriptEnabled = true

The most annoying problem is that I cannot access the camera pictures folder. I have also overloaded onPermissionRequest of WebChromeClient. If I let the web view unchanged by commenting the following line:

     webView.webViewClient = WebViewClient() <<--- When this is commented the app works fine 

Everything works fine, but the web view displays the address bar and I don't want it. I really do not understand why Google has produced such an ill-designed control compared to its competitors. Can anyone help me in finding a way of reproducing exactly the same capabilities of Chrome without displaying the address bar?

Sergiob
  • 838
  • 1
  • 13
  • 28

3 Answers3

0

Try setting webChromeClient instead of webViewClient, like this

webView.webChromeClient = WebChromeClient()
Alex Timonin
  • 1,872
  • 18
  • 31
0
Use Below Code : 

   web_view.settings.setSupportZoom(true)
                web_view.settings.builtInZoomControls = true
                web_view.settings.loadsImagesAutomatically = true
                web_view.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
                web_view.settings.javaScriptCanOpenWindowsAutomatically = true
                web_view.settings.setSupportMultipleWindows(true)
                web_view.settings.builtInZoomControls = true
                web_view.settings.javaScriptEnabled = true
                web_view.settings.setAppCacheEnabled(true)
                web_view.settings.databaseEnabled = true
                web_view.settings.domStorageEnabled = true
                web_view.settings.setGeolocationEnabled(true)
                web_view.settings.loadWithOverviewMode = true
                web_view.settings.useWideViewPort = true
                web_view.settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL
Sunil Kumar
  • 127
  • 2
  • 8
  • I still cannot access the pictures folder. I click on the button that should let me pick a picture but nothing happens. That is the most annoying of the problems I'm having – Sergiob Jun 19 '20 at 08:22
0
    for kotlin:
     val intent = Intent()
            intent.type = "image/*"
            intent.action = Intent.ACTION_GET_CONTENT
            startActivityForResult(Intent.createChooser(intent, "Select Picture"), 0)

for java:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),100);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == SELECT_IMAGE) {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                try {
                    Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), data.getData());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED)  {
            Toast.makeText(getActivity(), "Canceled", Toast.LENGTH_SHORT).show();
        }
    }
}
Sunil Kumar
  • 127
  • 2
  • 8