0

I'm using a webview to open a website. The problem I'm getting is after user clicks on a button, it always get stuck to the Loading dialog and doesn't show the expected results. But in Google Chrome or custom tabs, it works perfectly fine. I'm not overriding onPageFinished(), onPageStarted() or any other webview method, they are as it is. These are my webview settings:

    webView.getSettings().setLoadsImagesAutomatically(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    webView.getSettings().setSupportMultipleWindows(true);

    WebSettings settings = webView.getSettings();
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setAllowFileAccessFromFileURLs(true);

    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    String newUA= "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0";
    webView.getSettings().setUserAgentString(newUA);

    webView.clearFormData();
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);

    webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(true);

Just wanted to know what settings could be different in custom tabs and my webview that's causing the issue. And I think it's probably not possible but still asking is there any way to imitate the browser settings of custom tabs for the webview so that I can check if it works that way

Vishal Afre
  • 1,013
  • 3
  • 12
  • 39
  • 6
    custom tabs has nothing related to WebView. Custom tabs is just a chrome app launched in context of your own app. – Vladyslav Matviienko Jan 18 '19 at 07:48
  • 1
    You have to refer this https://developer.chrome.com/multidevice/android/customtabs – Nitin Thakor Jan 18 '19 at 07:51
  • @VladyslavMatviienko yes I know, but I can't use custom tabs because I need some execution of javascript in my webview. So just want to know why it's not working in webview when the website is same in both case – Vishal Afre Jan 18 '19 at 07:56
  • 1
    the WebView is not designed to work as a full-functional web browser, and some features might not work in it. You probably need to check the logcat when you are facing problems and see if there are any message about it there. – Vladyslav Matviienko Jan 18 '19 at 08:04

0 Answers0