AppCompat v23.2 — DayNight
Chris Banes
26410
public void onClick(View view) {
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
// Night mode is not active, we're in day time
Toast.makeText(getApplicationContext(), "Day Time", Toast.LENGTH_SHORT).show();
case Configuration.UI_MODE_NIGHT_YES:
// Night mode is active, we're at night!
Toast.makeText(getApplicationContext(), "Night Time", Toast.LENGTH_SHORT).show();
case Configuration.UI_MODE_NIGHT_UNDEFINED:
// We don't know what mode we're in, assume notnight
Toast.makeText(getApplicationContext(), "Don't know", Toast.LENGTH_SHORT).show();
}
}My app shows Toast three times, when I set up MODE_NIGHT_NO in my Activity. Why?
Upd. Sorry. I forgot about break