CopyPastor

Detecting plagiarism made easy.

Score: 0.8117344975471497; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2016-03-21
by Md. Sajedul Karim

Original Post

Original - Posted on 2015-08-13
by code\_geek



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can try this code into your activity
private void startWebView(WebView webView,String url) { webView.setWebViewClient(new WebViewClient() { ProgressDialog progressDialog; public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); } public void onLoadResource (WebView view, String url) { if (progressDialog == null) { progressDialog = new ProgressDialog(SponceredDetailsActivity.this); progressDialog.setMessage("Loading..."); progressDialog.show(); } } public void onPageFinished(WebView view, String url) { try{ if (progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; } }catch(Exception exception){ exception.printStackTrace(); } } }); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(url); }
Call this method using this way:
startWebView(web_view,"Your Url");
Sometimes if URL is dead it will redirected and it will come to onLoadResource() before onPageFinished method. For this reason progress bar will not dismis. To solve this issue see [my this Answer][1].
Thanks :)

[1]: https://stackoverflow.com/a/36128241/3073945
Try this code...
private void startWebView(String url) { //Create new webview Client to show progress dialog //When opening a url or click on link webView.setWebViewClient(new WebViewClient() { ProgressDialog progressDialog; //If you will not use this method url links are opeen in new brower not in webview public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } //Show loader on url load public void onLoadResource (final WebView view, String url) { if (progressDialog == null) { // in standard case YourActivity.this progressDialog = new ProgressDialog(view.getContext()); progressDialog.setMessage("Loading..."); progressDialog.show(); } } public void onPageFinished(WebView view, String url) { try{ if (progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; } }catch(Exception exception){ exception.printStackTrace(); } } }); // Javascript inabled on webview webView.getSettings().setJavaScriptEnabled(true); // Other webview options /* webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(false); webView.getSettings().setBuiltInZoomControls(true); */ /* String summary = "<html><body>You scored <b>192</b> points.</body></html>"; webview.loadData(summary, "text/html", null); */ //Load url in webview webView.loadUrl(url); }

        
Present in both answers; Present only in the new answer; Present only in the old answer;