I’m building an Android app and I need to have two different themes for day and night modes: different colors and different drawables.
What is the best way to do it?
I’ve noticed a service called UiModeManager but I’m not sure if it behaves like I expect. I’ve placed two different bitmaps (with the same name) in drawable-mdpi and drawable-night-mdpi and I created an Activity that shows that bitmap.
I’ve tried to switch the day/night mode by putting in the onCreate():
UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
But Android always shows the “day” version.
Any suggestion or hint would be appreciated.
Thanks,
Maurizio
The HoneycombGallery Sample has a day/night switcher for the theme (background + drawables etc.). They only defined two themes and set it in code via
setTheme(). Maybe that helps youEdit: According to docs setNightMode() “Changes to the night mode are only effective when the car or desk mode is enabled on a device.”