title: How to add an activity before MainActivity.java
body: <p>How do you add an activity (SplashActivity.java in my case) that launches automatically before the MainActivity? I've added in the below code but the activity is still being skipped over. I've already tried going to Edit Configurations -&gt; Launch -&gt; Default Activity. And the Splash Activity is the only activity with an intent filter.</p>
  <p><strong>SplashActivity.java</strong></p>
  <pre><code>package com.example.simplesplashscreen;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.drawable.AnimatedVectorDrawable;
  import android.graphics.drawable.Drawable;
  import android.os.Bundle;
  import android.util.Log;
  
  import androidx.appcompat.widget.AppCompatImageView;
  
  public class SplashActivity extends Activity implements InterfaceSplash {
      private AppCompatImageView image;
      private AnimatedVectorDrawable animation;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_splash);
          image = (AppCompatImageView) findViewById(R.id.splashobject);
          launchSplashScreen();
          dismissSplashScreen();
      }
  
      @Override
      public void launchSplashScreen() {
          super.onStart();
          Drawable d = image.getDrawable();
          if (d instanceof AnimatedVectorDrawable) {
              Log.d(&quot;testanim&quot;, &quot;onCreate: instancefound&quot; + d.toString());
              animation = (AnimatedVectorDrawable) d;
              animation.start();
          }
      }
  
      @Override
      public void dismissSplashScreen() {
          // Start Main Activity
          startActivity(new Intent(SplashActivity.this,MainActivity.class));
          finish();
      }
  }
  </code></pre>
  <p><strong>AndroidManifest.java</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.simplesplashscreen&quot;&gt;
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
          android:supportsRtl=&quot;true&quot;
          android:theme=&quot;@style/Theme.SimpleSplashScreen&quot;&gt;
          &lt;activity
              android:name=&quot;.SplashActivity&quot;
              android:exported=&quot;true&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
                  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=&quot;.MainActivity&quot;
              android:exported=&quot;true&quot;&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=&quot;.SecondActivity&quot;
              android:exported=&quot;true&quot;&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>