【问题标题】:splashScreen.setOnExitAnimationListener() not called when using CustomSplashScreen with debugger将 CustomSplashScreen 与调试器一起使用时未调用 splashScreen.setOnExitAnimationListener()
【发布时间】:2021-08-27 12:03:21
【问题描述】:

我正在使用依赖项“androidx.core:core-splashscreen:1.0.0-alpha01”作为我的启动画面。在 IDE 和项目中使用 Android Gradle Plugin 7.0.1(带有 Android Studio Arctic Fox 2020.3.1 Patch 1)、Kotlin 1.5.20 和 Java 11 设置。

我使用自己的 SplashActivity 来根据情况将用户路由到不同的活动(进行反根检查、身份验证检查等)。

我的 onCreate() 有以下内容:

val splashScreen = installSplashScreen()
splashScreen.setOnExitAnimationListener { routeToOtherActivity() }

而且我从不调用 setContentView()。

其他一切都根据迁移指南进行设置:

https://developer.android.com/about/versions/12/splash-screen-migration

问题是,当我在调试模式下通过 Android Studio 运行我的应用程序时,Theme.App.Starting 主题中设置的 windowSplashScreenAnimatedIcon drawable 永远不会显示,并且永远不会调用 setOnExitAnimationListener。所以我的应用程序停留在 SplashActivity 中,并且永远不会发生路由。当我使用应用程序启动器手动再次运行我的应用程序时,它按预期运行,并且绘图可见并且路由成功,因为侦听器按预期工作。

有什么解决办法吗?是否有任何未解决的问题? (没找到)

我在物理设备 Google Pixel 4 XL 上运行该应用。

【问题讨论】:

    标签: android debugging migration splash-screen


    【解决方案1】:

    因此,如果您不调用 setContentView(),则永远不会调用 setOnAnimationExitListener,因为活动不会绘制。因此,启动画面永远不会被删除。

    修复方法是在 installSplashScreen() 之前删除侦听器并调用 routeToOtherActivity() 并且行为将符合预期。

    来源:https://issuetracker.google.com/issues/197906327

    【讨论】:

    • 它适用于Android L,即使没有setContentView也会调用setOnExitAnimationListener。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多