title: Basic Android launcher splash screen
body: <p>I'm new to writing code and apologize for what I am guessing is probably a very simple question. I followed Android's <a href="https://developer.android.com/training/basics/firstapp" rel="nofollow noreferrer">Build your first app</a> guide. Next, I'm trying to add a launcher splash screen by following a number of tutorials (<a href="https://android.jlelse.eu/right-way-to-create-splash-screen-on-android-e7f1709ba154" rel="nofollow noreferrer">this being one of them</a>). When I run the app in the emulator it loads so fast that I can't tell if the splash screen works. Is there a way to temporarily slow down the emulator to check the splash screen? Also the app crashes when the Send button is clicked which doesn't make sense because the <code>sendMessage</code> function exists in the MainActivity.</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.myfirstapp, PID: 9242
      java.lang.IllegalStateException: Could not find method sendMessage(View) in a parent or ancestor Context for android:onClick attribute defined on view class androidx.appcompat.widget.AppCompatButton with id 'button'
          at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:436)
          at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:393)
          at android.view.View.performClick(View.java:7125)
          at android.view.View.performClickInternal(View.java:7102)
          at android.view.View.access$3500(View.java:801)
          at android.view.View$PerformClick.run(View.java:27336)
          at android.os.Handler.handleCallback(Handler.java:883)
          at android.os.Handler.dispatchMessage(Handler.java:100)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7356)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>
  <p>I'm honestly not sure what is wrong or if the app is just so small that a splash screen won't show. I'm also not sure the best way to share my project here. So below is all of the code.</p>
  <p>AndroidManifest.xml</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.myfirstapp&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/AppTheme&quot;&gt;
  
          &lt;activity android:name=&quot;.SplashActivity&quot;
              android:theme=&quot;@style/SplashTheme&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;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity android:name=&quot;.DisplayMessageActivity&quot;
                    android:parentActivityName=&quot;.MainActivity&quot;&gt;
              &lt;!-- For API 15 --&gt;
              &lt;meta-data
                  android:name=&quot;android.support.PARENT_ACTIVITY&quot;
                  android:value=&quot;.MainActivity&quot; /&gt;
          &lt;/activity&gt;
          &lt;activity android:name=&quot;.MainActivity&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  <p>MainActivity.kt</p>
  <pre><code>package com.example.myfirstapp
  
  import android.content.Intent
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.view.View
  import android.widget.EditText
  
  const val EXTRA_MESSAGE = &quot;come.example.myfirstapp.MESSAGE&quot;
  
  class MainActivity : AppCompatActivity()
  {
      override fun onCreate(savedInstanceState: Bundle?)
      {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
      }
  
      //Called when user taps Send button
      fun sendMessage(view: View)
      {
          val editText = findViewById&lt;EditText&gt;(R.id.editTextTextPersonName)
          val message = editText.text.toString()
          val intent = Intent(this, DisplayMessageActivity::class.java).apply {putExtra(EXTRA_MESSAGE, message)}
          startActivity(intent)
      }
  }
  </code></pre>
  <p>DisplayMessageActivity</p>
  <pre><code>package com.example.myfirstapp
  
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.widget.TextView
  
  class DisplayMessageActivity : AppCompatActivity()
  {
      override fun onCreate(savedInstanceState: Bundle?)
      {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_display_message)
  
          //Get the Intent that started this activity and extract the string
          val message = intent.getStringExtra(EXTRA_MESSAGE)
  
          //Capture the layout's TextView and set the string as its text
          val text = findViewById&lt;TextView&gt;(R.id.textView).apply {text = message}
      }
  }
  </code></pre>
  <p>SplashActivity</p>
  <pre><code>package com.example.myfirstapp
  
  import android.os.Bundle
  import androidx.appcompat.app.AppCompatActivity
  
  class SplashActivity : AppCompatActivity()
  {
      override fun onCreate(savedIntanceState: Bundle?)
      {
          setTheme(R.style.AppTheme)
          super.onCreate(savedIntanceState)
          setContentView(R.layout.activity_main)
      }
  }
  </code></pre>
  <p>drawable splash_background.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layer-list xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:opacity=&quot;opaque&quot;&gt;
      &lt;item android:drawable=&quot;@color/colorPrimary&quot; /&gt;
      &lt;item&gt;
          &lt;bitmap android:gravity=&quot;center&quot; android:src=&quot;@mipmap/ic_launcher&quot; /&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  <p>values styles.xml</p>
  <pre><code>&lt;resources&gt;
      &lt;!-- Base application theme. --&gt;
      &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.Light.DarkActionBar&quot;&gt;
          &lt;!-- Customize your theme here. --&gt;
          &lt;item name=&quot;colorPrimary&quot;&gt;@color/colorPrimary&lt;/item&gt;
          &lt;item name=&quot;colorPrimaryDark&quot;&gt;@color/colorPrimaryDark&lt;/item&gt;
          &lt;item name=&quot;colorAccent&quot;&gt;@color/colorAccent&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;!-- Splash Screen theme. --&gt;
      &lt;style name=&quot;SplashTheme&quot; parent=&quot;Theme.AppCompat.NoActionBar&quot;&gt;
          &lt;item name=&quot;android:windowBackground&quot;&gt;@drawable/splash_background&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>Sorry for the novice question, and I hope I'm not breaking any rules by posting it, but would appreciate some guidance. Thanks!</p>
  <p>Edit - updated error after help from <a href="https://stackoverflow.com/users/10778405/s-t">S T</a></p>