javascriptandroidandroid-webviewandroid-websettings

Web view desn't load on Oreo


Web view content doe not load in Oreo android. It keeps loading and then show white screen what could be the possible issue ?

   `WebView mwebView = (WebView) findViewById(R.id.myWebView);
                WebSettings webSettings = mwebView.getSettings();
                webSettings.setJavaScriptEnabled(true);




                //improve webView performance
                mwebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
                mwebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
                mwebView.getSettings().setAppCacheEnabled(true);
                mwebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                webSettings.setDomStorageEnabled(true);
                webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
                webSettings.setUseWideViewPort(true);
                webSettings.setSavePassword(true);
                webSettings.setSaveFormData(true);
                webSettings.setEnableSmoothTransition(true);


                mwebView.loadUrl("http://google.com");
              // mwebView.loadUrl("http://invol.co/aff_m?offer_id=699&aff_id=2189&source=deeplink_generator&url=http%3A%2F%2Fwww.motherhood.com.my%2F&aff_sub=LKQ2IVP4&aff_sub2=CHINTHAKA &aff_sub3=BO3DH1NY");

                //force links open in webview only
                mwebView.setWebViewClient(new MyWebviewClient());` 

Solution

  • Try some of these options as well:

    webSettings.setDatabaseEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }