【发布时间】:2022-01-13 08:51:53
【问题描述】:
我们的应用(存在于 Playstore 中,下载量超过 1 万次)有新的 Android 12 用户,他们因自定义启动屏幕活动而面临崩溃,在该活动中仅检查用户是否已登录。此崩溃的唯一可能原因可能是Android 12中引入了新的Splash screen api。但是即使集成了它,这在android 12手机上也不起作用。请帮助我在下面的代码中解决问题。
我正在使用图书馆:
实现'androidx.core:core-splashscreen:1.0.0-alpha02'
在splash.xml:
<resources>
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@drawable/appback</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/applogo</item>
<item name="postSplashScreenTheme">@style/Theme.AppName</item>
</style>
</resources>
在应用程序级别和活动级别声明的主题使用:
android:theme="@style/Theme.App.Starting"
在我的主屏幕(用户不登录无法访问主屏幕),就在上面设置contentView:
splashScreen.setKeepVisibleCondition((SplashScreen.KeepOnScreenCondition) () -> {
if (user_id.equals("")){
startActivity(new Intent(context,LoginActivity.class));
finish();
}
return true;
});
【问题讨论】:
-
您有崩溃消息或堆栈跟踪吗?
-
它从 Nogoat 到 Android 11 都可以工作。该应用程序只是停止,不显示任何内容或在 Crashlytics 中记录崩溃。我没有 Android 12,所以无法进行 USB 调试。
-
您是否尝试过使用 API 31 的模拟器?
-
是实际上由于设备限制,模拟器没有启动,这就是为什么无法在那里测试的原因。您发现我的代码有什么问题吗?
-
我假设你使用了
installSplashScreen(Activity)?
标签: java android splash-screen android-12