A launcher icon that changes (today's date on a calendar icon)
androidlauncheractivity-aliasiconsadaptive-iconpackagemanager
Google's Calendar and Clock icons show today's date or the time because the Pixel launcher draws them specially. Launchers do not draw live icons for third-party apps. The workaround is to ship one icon per state and swap which one the launcher sees, using activity aliases. Justin's Calendar app (io.jhampton.calendar, 0.3.0, 2026-10-28) shows the day of the month this way.
How it works
- The real activity (
MainActivity) loses itsLAUNCHERcategory (it keepsMAINplus any other filters, such asAPP_CALENDAR). - The manifest declares
<activity-alias>entries pointing at it, each with theMAIN/LAUNCHERfilter and its ownandroid:icon/android:roundIcon: .Launcher: a plain icon,enabledby default, seen only before the app first runs..Day1….Day31:android:enabled="false", icons@mipmap/ic_day_N.- On every start,
PackageManager.setComponentEnabledSetting(..., DONT_KILL_APP)enables today's alias and disables whichever others are showing. The launcher sees one app whose icon changed. - Enable the new alias first, then disable the old ones. If the app has zero launcher entries even briefly, some launchers drop the home-screen shortcut instead of moving it. Launcher3 (Pixel) re-points a shortcut to the remaining alias.
- Only touch what is showing: a day alias in
COMPONENT_ENABLED_STATE_DEFAULTis disabled by the manifest, while.Launcherin DEFAULT is enabled. Calling the setter for all 31 every time is wasted work and makes some launchers refresh. - Alias class names are written relative to the manifest namespace, not the application id, so a
.debugbuild withapplicationIdSuffixstill usesio.jhampton.calendar.Day5. Build theComponentNamefrom the namespace constant.
Keeping it current
Call the sync from Application.onCreate, the activity's onResume, and a receiver for an exact alarm at next midnight plus 2 s, BOOT_COMPLETED, MY_PACKAGE_REPLACED, TIME_SET and TIMEZONE_CHANGED. The receiver re-arms the next midnight alarm each time. Scheduling details are in Alarms and timers that ring on time (Android clock apps).
Generating 31 icons
Script it. The Calendar app's tool/make_icon.py writes, per day, an adaptive icon (mipmap-anydpi-v26/ic_day_N.xml) with a vector foreground and a monochrome layer for themed icons (the number cut out of the page with an even-odd fill). The digits are a real font (Noto Sans Bold) converted to vector path data with fontTools, so no font file or bitmap is needed at runtime.
Costs
- 31 extra manifest entries and 31 vector drawables; the APK grows a little.
- Changing component state can make a launcher re-sort or briefly blink the icon. Do it once a day, not on every resume when nothing changed.
- Verified on the emulator's Pixel launcher (an update from the plain-icon release, then a midnight rollover with the clock set to 23:59:50). Other launchers' shortcut handling varies, so check on the target phone.
See also
- Alarms and timers that ring on time (Android clock apps)
- Building a calendar app on Android's calendar provider