applications – Splash screen background color doesn’t match app theme colors android java

Stackoverflow!
I have an alert dialog containing radio switch, which makes app change default theme with selected mode and when app restarts, app loads night mode state using shared preferences method:
PreferenceRepository.class:

public class PreferenceRepository {
SharedPreferences mySharedPref ;
public PreferenceRepository(Context context) {
    mySharedPref = context.getSharedPreferences("filename",Context.MODE_PRIVATE);
}
//sets Night mode state to shared preferences
public void setNightModeState(int state) {
    SharedPreferences.Editor editor = mySharedPref.edit();
    editor.putInt("NightMode",state);
    editor.apply();
}
// returns NightModeState
public int NightModeState(){
    return mySharedPref.getInt("NightMode", 2);
}

//loads night mode state when called
public void loadTheme(){
    switch(NightModeState()){
        case 0:
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
            break;
        case 1:
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
            break;
        case 2:
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
            break;
    }
}

}

ThemeChoiceDialog.class:

public class ThemeChoiceDialog extends DialogFragment {
    PreferenceRepository preferenceRepository;
    int position;
    @NonNull
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        preferenceRepository = new PreferenceRepository(requireActivity().getBaseContext());
        position = preferenceRepository.NightModeState();
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        final String() list = requireActivity().getResources().getStringArray(R.array.theme_choice);

        builder.setTitle(R.string.select_theme)
                .setSingleChoiceItems(list,position , (dialogInterface, i) -> position = i)
                .setPositiveButton("Ok", (dialogInterface, i) -> {
                    preferenceRepository.setNightModeState(position);
                    restartApp();
                })
                .setNegativeButton("Cancel", (dialogInterface, i) -> {
                });

        return builder.create();
    }

    private void restartApp() {
        Intent i = new Intent(getContext(), MainActivity.class);
        startActivity(i);
    }
}

MainActivity.class:

public class MainActivity extends AppCompatActivity {

    PreferenceRepository preferenceRepository;

    @SuppressLint({"NonConstantResourceId", "SourceLockedOrientationActivity"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        preferenceRepository = new PreferenceRepository(this);
        preferenceRepository.loadTheme();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button themeDialog = findViewById(R.id.theme_dialog);

        themeDialog.setOnClickListener(v -> Continue());
    }

    //Continue button which transfers you to another (IndexActivity) activity
    private void Continue() {
        DialogFragment themeChoiceDialog = new ThemeChoiceDialog();
        themeChoiceDialog.setCancelable(true);
        themeChoiceDialog.show(getSupportFragmentManager(), "Theme Choice Dialog");
    }
}

For full project, visit my github link

All I want to achieve, is to have black background color in my splash screen when the app’s Night mode is ON and have white background of when Night mode is on (and I hope when Night mode is follow_system, it will set the background itself)
(I have the same question in stackoverflow “main”, here’s the link)