Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 12 Splash Screen Icon Not Displaying

I am seeing a weird issue with a new app that I am starting. I am utilizing the new Android 12 splash screen API to create my splash screen and I followed the guide provided by Google to do so. I included core-splashscreen in my project to provide compatibility with older versions of Android OS. When I run the app, I see the splash screen as expected on older OS versions like API 30, but when I run it on API 31, the splash screen icon that I provide is not displayed. The background color that I specify is displayed, but the icon is not there at all. I have tried this with a drawable asset as well as a mipmap and nothing is working. I am stumped as every tutorial I find shows the same steps I have followed and screenshots of their working splash screens, but I am not having any luck.

For context here is my splash screen style definition for v31:

<style name="Theme.Splash" parent="Theme.SplashScreen">
    <item name="android:windowSplashScreenBackground">@color/orange_7A</item>
    <item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_foreground</item>
    <item name="postSplashScreenTheme">@style/Theme.App</item>
</style>

I have an identical style for all other OS versions except I'm using "windowSplashScreenAnimatedIcon" instead of "android:windowSplashScreenAnimatedIcon". I have tried v31 with and without the "android:" in front of the item names and neither work. Here is my MainActivity.kt:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    installSplashScreen()
    
    setContent {
        MyVeevaTheme {
            Login()
        }
    }
}

I am also setting the "android:theme" property to my splash style in my AndroidManifest.xml. I know the splash style is being applied because it honors the background color, but it is not showing the icon for some reason even though the icon shows fine for older OS versions. Thanks in advance for any help you can give.

like image 359
Joseph Hawkes-Cates Avatar asked Nov 02 '21 15:11

Joseph Hawkes-Cates


People also ask

How do I show splash screen?

The most straightforward way to create a simple splash screen was to create a dedicated theme overriding android:windowBackground with a drawable containing branding colors or a bitmap of a logo. The theme was set as an attribute of the launcher activity in AndroidManifest. xml.

How do I show splash screen only once?

It is important to check that the first activity which opens when the app is launched is MainActivity. java (The activity which we want to appear only once). For this, open the AndroidManifest. xml file and ensure that we have the intent-filter tag inside the activity tag that should appear just once.

How splash screen is implemented in Android?

By default, SplashScreen uses the windowBackground of your theme if it's a single color and the launcher icon. The customization of the splash screen is done by adding attributes to the app theme. Your app's splash screen can be customized in any of the following ways: Setting theme attributes to change its appearance.


Video Answer


2 Answers

TL;DR kill the app and run from the launcher, icon does not show up when run from Android Studio.

Adding my comment here as an answer for better visibility.

I did figure out how to get it to show. I was following this tutorial to set up a base project to recreate the issue and I noticed the note the author put right near the bottom that mentions that just running the app doesn't show the full splash screen. You have to kill it and open the app from the launcher. Once I did that, I was able to see my splash screen. Annoying, but at least I have a way to test it now. I did go ahead and log a bug report for this as well, but I have a work around for now. Thanks for everyone's answers/comments!

like image 192
Joseph Hawkes-Cates Avatar answered Nov 11 '22 04:11

Joseph Hawkes-Cates


folks as per the document installSplashScreen() should have been called prior to super.onCreate()

like image 36
Muhammad Ahmed AbuTalib Avatar answered Nov 11 '22 03:11

Muhammad Ahmed AbuTalib