title: Android display Splash-Screen while loading
body: <p>I have an Android App, which shows a "Splash Screen" for 3 seconds. After that, the MainActivity gets loaded.</p>
  
  <p>Unfortunately the MainActivity takes additional ~4 seconds to load. On first startup even longer. However when the App is loaded, everything runs smooth.</p>
  
  <p>Now how can I achieve it, that the MainActivity gets loaded, during the display of the Splash Screen? It just should display an image until the whole thing loaded completely.
  I have read about Async-Task, but I'm not sure where to put it and how to use it properly. Can someone help me please?</p>
  
  <p><strong>SplashScreen.java</strong></p>
  
  <pre><code>public class SplashScreen extends Activity {
      private static int SPLASH_TIME_OUT = 3000;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_startup);
  
          new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                  Intent i = new Intent(SplashScreen.this, MainActivity.class);
                  startActivity(i);
                  finish();
              }
          }, SPLASH_TIME_OUT);
      }
  }
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity implements OnClickListener, MediaController.MediaPlayerControl {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //Some heavy processing
          //starting services
          //starting Google Text to Speech
          //and so on...
  
      }
  
  }
  </code></pre>