Android light, dark mode not applied with splash screen api

Viewed 12

I am using DayNight theme in my code. When I switch theme from system, theme was changed without closing and reopening the app. But When I integrated Splash screen api in the code, it doesn't work. I have to close the app and reopen for theme changes to be applied. The splash screen library version is:

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

Splash screen theme is:

 <style name="Theme.Splash" parent="Theme.SplashScreen">
    <item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
    <item name="android:navigationBarColor">@android:color/transparent</item>
    <item name="postSplashScreenTheme">@style/Theme.Shelf</item>
    <item name="windowSplashScreenBackground">@color/white_back_color</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/avd_anim</item>
    <item name="windowSplashScreenAnimationDuration">1500</item>
</style>

Post splash screen theme is:

<style name="Theme.Shelf" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/purple_200</item>
    <item name="colorPrimaryVariant">@color/purple_700</item>
    <item name="colorOnPrimary">@color/black</item>
</style>

I have color folder for both day and night. The problem is when I switch theme from system menu, the app theme is not changed at the instant.

0 Answers
Related