'Here is a question for Android Splash Screen implementation "androidx.core:core-splashscreen:1.0.0-beta01"
We need to designed for identify whether the user login or not?It means that We need to designed a routes to decide which Activity we need to display after the splash screen. How we can write code for that. As we write a SplashActivity as a routes, it will has white screen and become slower than other apps. Thanks a lot
Solution 1:[1]
There is an answer for your question in the official documentation. Please, take a look https://developer.android.com/guide/topics/ui/splash-screen/migrate
It can be implemented in the following way:
//let's imagine this is your SplashScreen, the starting point of the app
class RoutingActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
val splashScreen = installSplashScreen()
super.onCreate(savedInstanceState)
// Keep the splash screen visible for this Activity
// it means that there will be only your splash screen visible
// since we don't set "setContentView(resId : Int)"
splashScreen.setKeepOnScreenCondition { true }
//after you've checked if user is logged in, show the other activity
startSomeNextActivity()
finish()
}
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Valery M |
