我已经将Android新的闪屏API集成到了我的应用程序中.现在,我想将用户重定向到登录屏幕,如果用户已经登录,或者如果用户在完成闪屏API执行后没有登录,则重定向到注册屏幕.
这是我为闪屏API定义的主题
<style name="Theme.CustomSplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_logo</item>
<item name="windowSplashScreenAnimationDuration">5000</item>
<item name="postSplashScreenTheme">@style/Theme.SanskarEducation</item>
</style>
以下是该活动的代码
@RequiresApi(Build.VERSION_CODES.S)
override fun onCreate(savedInstanceState: Bundle?) {
val splash = installSplashScreen()
splash.setKeepOnScreenCondition { false }
setupSplashScreen()
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_login)
initialSetup()
}
@RequiresApi(Build.VERSION_CODES.S)
private fun setupSplashScreen() {
splashScreen.setOnExitAnimationListener { splashScreenView ->
val slideUp = ObjectAnimator.ofFloat(
splashScreenView,
View.TRANSLATION_Y,
0f,
-splashScreenView.height.toFloat()
)
slideUp.interpolator = AnticipateInterpolator()
slideUp.duration = 800L
slideUp.doOnEnd { splashScreenView.remove() }
slideUp.start()
}
}
我也try 过使用以下代码,但不起作用.它总是只重定向到登录屏幕.
val splash = installSplashScreen()
splash.setKeepOnScreenCondition { false }
我想知道我可以把我的条件放在哪里,以判断用户是否登录,以便我可以将用户重定向到特定屏幕.
先谢谢你