Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Projects › Advanced

Android Habit Tracker

A native Android app to build habits with streaks, reminders, a home-screen widget and offline storage.

Level: Advanced · Time: 2–3 weeks · Tech stack: Kotlin, Jetpack Compose, Room, WorkManager

Features to build

What you will learn

Step-by-step guide

1. Architecture: MVVM

UI (Compose) → ViewModel (state as StateFlow) → Repository → Room DAO. The UI only observes state.

2. Room

@Entity data class Habit(@PrimaryKey(autoGenerate = true) val id: Long = 0, val name: String, val target: Int, val reminder: String?)
@Entity(primaryKeys = ["habitId", "day"]) data class CheckIn(val habitId: Long, val day: String)

@Dao interface HabitDao {
  @Query("SELECT * FROM Habit") fun habits(): Flow<List<Habit>>
  @Insert(onConflict = OnConflictStrategy.IGNORE) suspend fun checkIn(c: CheckIn)
}

The composite primary key stops double check-ins on the same day.

3. Streaks

Walk back from today over the check-in days until a gap — compute it in the repository and expose it in the UI state.

4. Reminders

Schedule a periodic WorkManager job per habit; post a notification (ask for the POST_NOTIFICATIONS permission on Android 13+).

5. Stats

A Compose canvas heatmap for the last 12 weeks and completion percentages.

6. Ship it

Material 3 theming with dark mode, then publish an internal test on the Play Console (or share the APK).

Level it up

On your resume

Learn on Codify