title: Where to put welcome activity code
body: <p>I searched a lot but i did not find my answer. I have developed an android application where on the very first lunch user will be shown a welcome screen made of viewpager. The problem is i don't know which place is the  best to put the welcome activity code in my application.</p>
  
  <p>The simplest way it could be that in the main activity at the very fist line even before <strong>super.onCreate()</strong>, inside onCreate method where i try to get the shared preference value and then evaluate whether it is fist lunch. If it is, then i start the welcome activity as shown below</p>
  
  <pre><code>public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
          boolean welcome = sharedPreferences.getBoolean(getString(R.string.key_welcome), true);
          if (welcome) {
              // go and start welcoming activity
              Intent intent = new Intent(this, WelcomeSlideActivity.class);
              startActivity(intent);
          }
  
  
          super.onCreate();
      }
  }
  </code></pre>
  
  <p>But i found another approach to deal with it. It is Application class. Since Application class is the first one, which runs even before any other codes in my application. So i thought, i would be nice to do it there as shown below</p>
  
  <pre><code>public class App extends Application {
  
      @Override
      public void onCreate() {
          super.onCreate();
  
          SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
          boolean welcome = sharedPreferences.getBoolean(getString(R.string.key_welcome), true);
          if (welcome) {
              // go and start welcoming activity
              Intent intent = new Intent(this, WelcomeSlideActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              startActivity(intent);
          }
      }
  }
  </code></pre>
  
  <p>So i am in dilemma, which one would be the best option to choose. And i am even not sure if i am doing it in the right way since there is no such documentation in android developer website or anywhere.</p>