Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Progress Bar is not dismissing even though Page loading is finished
    primarykey
    data
    text
    <p>Progress Bar is not dismissing even though Page loading is finished I'm trying to load the url in the webview in background so that user doesn't able to recognize that it is some other website that opens.. I want them to think that the whatever is opening in the webview is the part of the application itself. Therefore I'm trying to open url in background and till the time url loads I want progress bar to appear but as page loaded I'm dismissing progress bar but it continues to appear.. it is not dismissing, thats the problem.. please help me out</p> <p>Here is my code...</p> <pre><code>package com.example.urlopeningwithprogressbar; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ProgressDialog; import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity { ProgressDialog pg; Background bg; WebView wv; Button b1; static boolean buttonpressed=false; @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); b1=(Button)findViewById(R.id.button1); wv = (WebView)findViewById(R.id.webView1); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub bg = new Background(); bg.execute(); } }); } public void progress(){ pg = new ProgressDialog(MainActivity.this); pg.setTitle(""); pg.setMessage("Please Wait........."); pg.setCancelable(false); pg.setIndeterminate(true); pg.show(); } class Background extends AsyncTask&lt;Void, Void, Void&gt; { @SuppressLint("SetJavaScriptEnabled") @Override protected Void doInBackground(Void... arg0) { // TODO Auto-generated method stub try{ wv.loadUrl("URL"); }catch(Exception e){ e.printStackTrace(); } wv.getSettings().setJavaScriptEnabled(true); wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setUseWideViewPort(true); wv.getSettings().setBuiltInZoomControls(true); // wv.setWebViewClient(new ourViewClient()); return null; } @Override protected void onPostExecute(Void result) { Toast.makeText(MainActivity.this, "Process Complete", Toast.LENGTH_SHORT).show(); } @Override protected void onPreExecute() { Toast.makeText(getApplicationContext(), "pre execute is working??", Toast.LENGTH_SHORT).show(); progress(); } } public class myWebClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // TODO Auto-generated method stub super.onPageStarted(view, url, favicon); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { // TODO Auto-generated method stub super.onPageFinished(view, url); pg.dismiss(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload