DEV Community

Cover image for My homescreen was chaos. Not anymore.
niluved
niluved

Posted on

My homescreen was chaos. Not anymore.

I built an Android widget that learns your app habits — without sending anything to a server

I had a problem. My home screen was organized chaos: folders for Work, Music, Streaming, Chat, Hobbies. Every evening I’d open the same three folders in the same order just to launch the same handful of apps. I wasn't finding apps — I was repeating a ritual.

My phone already knows what I do and when I do it — it just never puts that knowledge to use. So I built Habits to teach it to repeat what it has already seen.


The constraint: Android only remembers a few days

The predictive feature needs the Usage Access permission. The problem? Android only retains raw usage history for a few days by default. After that, the data is gone.

I needed enough history to recognize actual patterns — not just what I opened yesterday, but what I open at 8 AM on a typical Tuesday. That requires weeks of accumulated history, and Android doesn’t give you that out of the box.

I also wasn't willing to ship app usage logs to a backend. This widget was going to be smart, but only if it could be smart without touching a server.


How it works under the hood

Habits accumulates usage history on the device — timestamps, durations, which apps — storing it for long enough to smooth out noise and detect recurring patterns. A statistical model then correlates the current time slot with past behavior to assign relevance scores to installed apps.

The model balances two signals:

  • Long-term habits (default weight: 75%): apps you tend to use at this time of day over the past weeks
  • Short-term context (default weight: 25%): apps you opened in the last few minutes, which suggest what you’re about to do next

You can adjust the relative weight of each factor in settings, so the widget adapts to how predictable your routine actually is.


What the widget actually does

  • Surfaces apps contextually: morning coffee → news apps, Friday evening → streaming and music
  • Customizable grid (columns/rows) directly in widget settings
  • Monochromatic icon support natively — no third-party icon packs needed
  • Material You dynamic colors, custom backgrounds, adjustable icon sizes
  • Pin/exclude apps: keep essentials always visible, hide outliers
  • Full icon pack support if that's your setup
  • Export/import your history: the usage database can be exported and re-imported on a new device — your model follows you, no lock-in

The honest version (the stuff I'd want to know before installing)

  • Usage Access is required — the core feature doesn't work without it. The app prompts for it on first launch.
  • No accounts, no IAP, no ads — but also no cloud sync, no server fallback.
  • No magic: the predictions are based on patterns in your own history. If your habits are genuinely unpredictable (shift worker? seasonal routine?), the widget won't help much.

Stack

  • Kotlin, native Android
  • Jetpack Compose + Glance widget
  • Apache Commons Math for the statistical model
  • Local DataStore for historical usage accumulation

Feedback wanted

This is my first attempt at on-device predictive UX. Two things I'm actively grappling with:

  1. Model scope vs. accuracy: I'm deliberately keeping the model narrow (time-based patterns) to avoid permission sprawl. I'd love to hear from others who've tried adding signals like location or calendar overlap — what worked, what broke the battery.

  2. Detecting "out of pattern" periods: The model learns habits, but habits break. Vacations, travel, sick days — how do you signal to an on-device model that "this week is different" without adding heavy heuristics or extra permissions? I'm wary of turning this into a full scheduling system, but ignoring those periods makes predictions worse for a chunk of the year.

I'd love to hear from other Android devs — especially anyone who's hit the Android usage history wall or tried on-device prediction.

Play Store: https://play.google.com/store/apps/details?id=com.nick.applab.habits

Top comments (0)