title: Progress bar loading is not stopped when the activity is called second time
body: <p>I have created a welcome page(launcher) and included a progress bar.next activity will be displayed after this progress bar loading(for few seconds).For the first time,when the app is run,after few seconds the next activity is displayed.Now,when i press back button,welcome activity is being displayed.But this time,after few seconds,it is now calling the next activity(using Intent) like the first time.How to resolve this?
  The code is:</p>
  
  <pre><code>import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.ProgressBar;
  
  public class WelcomeActivity extends AppCompatActivity {
      ProgressBar p;
      private boolean mbActive;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_welcome);
          p = (ProgressBar) findViewById(R.id.progressBar);
          final Thread timerThread = new Thread() {
              @Override
              public void run() {
                  mbActive = true;
                  try {
                      int waited = 0;
                      while(mbActive &amp;&amp; (waited &lt; 1000)) {
                          sleep(200);
                          if(mbActive) {
                              waited += 200;
                              updateProgress(waited);
                          }
                      }
                  } catch(InterruptedException e) {
                  } finally {
                      onContinue();
                  }
              }
          };
          timerThread.start();
  
      }
      @Override
      public void onDestroy() {
          super.onDestroy();
      }
      public void updateProgress(final int timePassed) {
          if(null != p) {
              final int progress = p.getMax() * timePassed / 100;
              p.setProgress(progress);
          }
      }
  
      public void onContinue() {
          Intent intd=new Intent(this,MainActivity.class);
          startActivity(intd);
      }
  
  
  }
  </code></pre>