Jetpack (androidx) > Core
issue 197906327:"在调试模式下使用CustomSplashScreen
时splashScreen.setOnExitAnimationListener()
未调用"似乎没有任何修复,只有(不完美的)解决方法.
关于最后一个选项:
问题是在调试模式下使用CustomSplashScreen
类时不会调用setOnExitAnimationListener()
方法.这是因为CustomSplashScreen
类实际上并不在调试模式下显示.相反,系统会显示默认的闪屏.
但是,如果使用setOnExitAnimationListener()
方法,当default闪屏关闭时,侦听器仍将被调用.这是因为监听程序被附加到SplashScreen
interface,这是由CustomSplashScreen
类和默认闪屏实现的.
因此,即使在调试模式下使用CustomSplashScreen
类时不调用setOnExitAnimationListener()
方法,当关闭默认闪屏时仍会调用该方法.这意味着您可以使用侦听器启动应用程序的主要活动,即使在调试模式下也是如此.
例如,这将使用setOnExitAnimationListener()
方法在调试模式下启动应用程序的主要活动:
val splashScreen = installSplashScreen()
splashScreen.setOnExitAnimationListener {
// Start your app's main activity here.
startActivity(Intent(this, MainActivity::class.java))
}