Reputation: 18
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()
}
Upvotes: 0
Views: 1824
Reputation: 704
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.
Upvotes: 0