title: Splash screen redirecting wrong Activity android
body: <p>Basically i have a handler for a splash page which redirects to the main menu after 5 seconds.</p>
  
  <p>However, i also have a settings page which is seen on a first time setup, but whats happening is that it is thinking this is a splash page and is redirected after x seconds. I need this to not redirect on x seconds, just need the splash screen 'MainActivity' to redirect.</p>
  
  <p>Main Problem:</p>
  
  <p>First time setup loads Preferences.
  Problem: It redirects after 5 seconds.</p>
  
  <p>Whats supposed to happen:
  First time setup loads Preferences.
  Allows user to enter details and save.
  On next launch, splash page appears which redirects after 5 seconds.</p>
  
  <p>Heres is my code:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.mainactivity);
          new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                  final Intent mainIntent = new Intent(MainActivity.this, MainMenu.class);
                  MainActivity.this.startActivity(mainIntent);
                  MainActivity.this.finish();
              }
          }, 5000);
  
          // get shared preferences
          SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  
          // first time run?
          if (pref.getBoolean("firstTimeRun", true)) {
  
              // start the preferences activity
              startActivity(new Intent(getBaseContext(), Preferences.class));
  
              //get the preferences editor
              SharedPreferences.Editor editor = pref.edit();
  
              // avoid for next run
              editor.putBoolean("firstTimeRun", false);
              editor.commit();
  
          }
  
      }
  </code></pre>