0

i have a web view in my android app. it work fine in my phone .but when i test app in some other phone it dos not show anything until click on it.

this is my xml file:

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_gravity="center"
            android:orientation="vertical">

        <ProgressBar
            android:id="@+id/prog"
            android:layout_width="320dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            style="?android:attr/progressBarStyleHorizontal"
            android:indeterminate="true"

            />

        <WebView
            android:layout_width="320dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:id="@+id/webview"></WebView>
        </LinearLayout>

and this is my web view client code for loading url:

private void startWebView(WebView webView,String url) {

    webView.setWebViewClient(new WebViewClient() {
        ProgressDialog progressDialog;

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            isRedirected = true;
            return false;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            isRedirected = false;
        }

        public void onLoadResource (WebView view, String url) {

            if(isOnline()) {
                if (!isRedirected) {
                    mprogressbar.setVisibility(View.VISIBLE);
                    // if (progressDialog == null) {
                    //    progressDialog = new ProgressDialog(MainActivity.this);
                    //    progressDialog.setMessage("Loading...");
                    //   progressDialog.show();
                    // }
                }
            }else{
                //Toast.makeText(getApplicationContext(), "Internet is not avialable.Please check your connection!", Toast.LENGTH_LONG).show();


            }

        }
        public void onPageFinished(WebView view, String url) {
            try{
                isRedirected=true;
                mprogressbar.setVisibility(View.GONE);
                // if (!progressDialog.isShowing()) {
                //    progressDialog.dismiss();
                //    progressDialog = null;
                // }



            }catch(Exception exception){
                exception.printStackTrace();
            }
        }

    });

    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadData(url,"text/html", null);
}

please some body help. thank you

Shadman Adman
  • 383
  • 3
  • 12
  • Have you seen this? http://stackoverflow.com/questions/13500452/android-webview-renders-blank-white-view-doesnt-update-on-css-changes-or-html?noredirect=1&lq=1 http://stackoverflow.com/questions/15127762/webview-fails-to-render-until-touched-android-4-2-2 – baldguy Dec 06 '16 at 21:06
  • Thanks to Rahil2952 this answer helps me http://stackoverflow.com/a/26283890/4398123 – Shadman Adman Dec 07 '16 at 22:16

0 Answers0