I have an Android App, which shows a \"Splash Screen\" for 3 seconds. After that, the MainActivity gets loaded.
Unfortunately the MainActivity takes additional ~4 se
Just do like in this article: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
1 - create a XML layout like this for the splash screen. I called it "background_splash.xml"
-
2 - Then, go to the styles.xml and write a style like this:
3 - Write an activity to your splash. I called it SplashActivity.kt
package com.example.kissmoney
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}
}
4 - Finally, go to you AndroidManifest.xml and add you activity splash: (Note: don't remove nothing in the AndroidManifest, just add this befora the activity Main).
This is done. You don't need to worry about the time that your application will demand to start, the splash will be there just for enough time. When you MainActivity is ready, it will be showed.