[英]Application Crashing in Splash Screen on Android 12
我們的應用程序(在 Playstore 中下載超過 1 萬次)有新的 Android 12 個用戶面臨自定義啟動屏幕活動的崩潰,其中僅檢查用戶是否登錄。此崩潰的唯一可能原因可能是新的啟動屏幕api在Android 12中引入。但是即使集成后,這在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;
});
此屬性必須是顏色,而不是可繪制對象(除非您的可繪制對象是顏色)
<item name="windowSplashScreenBackground">@drawable/appback</item>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.