I added Splash screen. And If I change app theme by AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
in settings fragment I will redirect to first fragment (main\home fragment). If I remove splash from manifest Everything will be fine! So, what's the problem? May be i've made mistake when create splash window? I want to stay in settings fragment after I change theme.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.***********">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Todo">
<activity
android:name=".SplashScreen"
android:label="@string/app_name"
android:theme="@style/splashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:theme="@style/Theme.Todo.NoActionBar">
</activity>
</application>
Style for splash:
<style name="splashScreen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/background_splashscreen</item>
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryColor</item>
<item name="colorPrimaryVariant">@color/primaryColor</item>
<item name="colorAccent">@color/primaryColor</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
Window Background:
layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?attr/colorPrimary"/>
<item
android:gravity="center"
android:width="300dp"
android:height="300dp"
android:drawable="@drawable/ic_launcher_foreground"/>
</layer-list>
I'm using
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
and Tamplate "Navigation Drawer Actyvity" (Single Activity)