Is it possible to force android to ignore certain activities from switching day to night modes along with other activities?
At the moment a possible workaround is this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
// Set the local night mode to some value
getDelegate().setLocalNightMode(
AppCompatDelegate.MODE_NIGHT_...);
// Now recreate for it to take effect
recreate();
}
}
}
However, this forces me to recreate the activity every time. Is it possible to just create it automatically in MODE_NIGHT without recreating it irrespective of what has been set for the rest of the app?
Do it like this
public void onCreate(Bundle savedInstanceState) {
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// use this to keep mode after exit activity
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
super.onCreate(savedInstanceState);
}
Call setDefaultNightMode
or setLocalNightMode
before super.onCreate