title: Why this class starts the intent twice?
body: <p>I have my SplashScreen activity with AsyncTask to check for files if exist. If they exist starts MainActivity class else starts the Downloader class. </p>
  
  <p>The problem is when splashscreen is done, it runs the MainActivity intent twice or the Downloader intent twice. I am using android version GINGERBREAD</p>
  
  <pre><code>package com.example.myapp;
  
  import java.io.File;
  import android.app.Activity;
  import android.content.Intent;
  import android.content.pm.ActivityInfo;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.os.Environment;
  import android.view.Window;
  import android.view.WindowManager;
  
  public class SplashScreen extends Activity {
  
  // base path of application
  private final String basePath =  Environment.getExternalStoragePublicDirectory("MyApp").getAbsolutePath() +
                              "/files";
  // files to check
  private final String[] filenames = {
      "file1.txt",
      "file2.txt",
  };
  
  private boolean isOK = false;
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      getWindow().requestFeature(Window.FEATURE_NO_TITLE);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  
      setContentView(R.layout.activity_splash);
  
      Thread background = new Thread() {
          public void run() {
  
              try {
                  // Thread will sleep for 5 seconds
                  sleep(5 * 1000);
  
                  // After 5 seconds redirect to another intent
                  // If is ok to start
                  if (isOK) {
                      Intent i = new Intent(getBaseContext(), MainActivity.class);
                      startActivity(i);
                  }
                  // Else download required files
                  else {
                      Intent i = new Intent(getBaseContext(), DownloadScreen.class);
                      startActivity(i);
                  }
  
                  //Remove activity
                  finish();
  
              } catch (Exception e) {
  
              }
          }
      };
  
      // check if all required files exists
      new CheckFiles().execute(filenames);
  
      // start thread
      background.start();
  }
  
  @Override
  public void onBackPressed() {
      android.os.Process.killProcess(android.os.Process.myPid());
  }
  
  private class CheckFiles extends AsyncTask&lt;String, Void, Boolean&gt; {
  
      @Override
      protected Boolean doInBackground(String... filenames) {
  
          for (String filename : filenames) {
              File file = new File(basePath + filename);
  
              if (file.exists())
                  continue;
              else return false;
          }
  
          return true;
      }
  
      @Override
      protected void onPostExecute(Boolean result) {
          isOK = result;
      }
  
  }
  }
  </code></pre>