简体   繁体   中英

Application Crashing in Splash Screen on Android 12

Our app (live in playstore with over 10k downloads) has new Android 12 users who are facing crashes with custom splash screen activity where it is just checked if the user is logged in. The only possible reason for this crash can be the new Splash screen api introduced in Android 12. But even after integrating it, this does not workon android 12 mobile phone. Please help me navigate the problem in my code below.

I am using the library:

implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'

At 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>

Declared theme at both application level and activity level using:

android:theme="@style/Theme.App.Starting"

In my home screen (User cannot visit homescreen without logging in), just above set contentView:

splashScreen.setKeepVisibleCondition((SplashScreen.KeepOnScreenCondition) () -> {
            if (user_id.equals("")){
                startActivity(new Intent(context,LoginActivity.class));
                finish();
            }
            return true;
        });

This attribute has to be a color, not a drawable (unless your drawable is a color)

<item name="windowSplashScreenBackground">@drawable/appback</item>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM