'android12 Splash Screen Background Color for App own theme

My app has own theme(dark, light) independent of the system theme. I want to set SplashScreenBackgroundColor according to the My app theme.

<item name="android:windowSplashScreenBackground">@color/background</item>

Preference store my app theme setting value. and I set App theme My Application

class MyApplication: Application() {
    override fun onCreate() {
       super.onCreate()
           
       if(pref.isDarkMode) {
          AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
       } else {
          ..... 
       }
    }
}

but SplashScreenBackground get resource dependent of system theme.

How do I make it follow the app theme?

i search aosp(API LEVEL 31) and find that SplashScreenView attached Window.decorView, so I think SplashScreenView setTheme is after Application Oncreate(), but it isn't work.

Is it possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source