【问题标题】:Here is a question for Android Splash Screen implementation "androidx.core:core-splashscreen:1.0.0-beta01"这是关于 Android 启动画面实现“androidx.core:core-splashscreen:1.0.0-beta01”的问题
【发布时间】:2022-01-19 10:08:03
【问题描述】:

我们需要设计用于识别用户是否登录?这意味着我们需要设计一个路由来决定我们需要在启动屏幕之后显示哪个Activity。我们如何为此编写代码。当我们将 SplashActivity 编写为路由时,它会出现白屏并变得比其他应用程序慢。非常感谢

【问题讨论】:

    标签: android splash-screen


    【解决方案1】:

    您的问题在官方文档中有答案。请看https://developer.android.com/guide/topics/ui/splash-screen/migrate

    可以通过以下方式实现:

    //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()
     }
    

    ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      相关资源
      最近更新 更多