When I open the app, the splash is shown and then there is a black screen (for just 1 second), and then goes to the activity. How can I avoid this black screen?
I set the splash as a theme.
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (sharedPrefs.isUserLogged) {
startActivity(intentFor<MainActivity>().clearTask().newTask())
}else{
startActivity(intentFor<LoginActivity>().clearTask().newTask())
}
finish()
}
}
I set the splash style on my AndroidManifest.xml
<activity android:name=".view.splash.SplashActivity"
android:theme="@style/AppTheme.Launch">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
and in my style, I set a drawable for the background.
<style name="AppTheme.Launch">
<item name="android:windowBackground">@drawable/my_splash</item>
</style>