0

The application is stuck on the splash screen. No idea why? I have done everything the same as the documentation. Please look at my code and please tell.

Android Manifest.xml file code:

   <activity
        android:name=".ui.startup.StartupActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

styles.xml code

<style name="SplashTheme" parent="Theme.SplashScreen">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/splash</item>
</style>

app.gradle dependency Code:

implementation 'androidx.core:core-splashscreen:1.0.0-alpha01'

StartUpActivity Code:

 override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    installSplashScreen()
 }

 override fun onStart() {
    super.onStart()
    proceedNavigation()
 }
Sweta Jain
  • 3,248
  • 6
  • 30
  • 50
Umer Iqbal
  • 18
  • 6

1 Answers1

0

As per this documentation, you must call the installSplashScreen function in your main or launcher activity. You must call it before the setContentView.

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val splashScreen = installSplashScreen()
    setContentView(R.layout.activity_main)

You should also consider specifying the activity theme to the attribute postSplashScreenTheme so you can have separate themes for your splash screen and application.

Praj
  • 451
  • 2
  • 5