@Override public void recreate() { if (android.os.Build.VERSION.SDK_INT >= 11) { super.recreate(); } else { startActivity(getIntent()); } }
public static boolean isNightMode(AppCompatActivity activity) { int uiMode = activity.getResources().getConfiguration().uiMode; int dayNightUiMode = uiMode & Configuration.UI_MODE_NIGHT_MASK; if (SPUtils.getBoolean(MainActivity.CURRENT_NIGHT_MODE) && dayNightUiMode != Configuration.UI_MODE_NIGHT_YES) { activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); activity.recreate(); return true; } return false; }