title: How to finish current activity in Android
body: <p>I have an Android application.  I am making a loading screen with a progress bar.</p>
  
  <p>I entered a delay in the onCreate method.  When the timer finishes, I want to finish the current activity and start a new one.  </p>
  
  <p>It just gives me an exception when it calls the <code>finish()</code> method.</p>
  
  <pre><code>public class LoadingScreen extends Activity{
      private LoadingScreen loadingScreen;
      Intent i = new Intent(this, HomeScreen.class);
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.loading);
  
          CountDownTimer timer = new CountDownTimer(10000, 1000) //10 second Timer
          {
              public void onTick(long l) 
              {
  
              }
  
              @Override
              public void onFinish() 
              {
                  loadingScreen.finishActivity(0);
                  startActivity(i);
              };
          }.start();
      }
  }
  </code></pre>
  
  <p>How can I change the code so that it ends when the progress bar is done?</p>