Android Legacy State Standards

SkillMedia

Integrate ViewModel state with XML Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity; defer Compose state and generic Flow design to their specific skills.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Android Legacy State Standards skill

What this skill tells your AI

The instructions your AI receives, as published by hoangnguyen0403/agent-skills-standard in skills/android/android-legacy-state/SKILL.md and read by ahel’s review.

Priority: P1 (HIGH)

Implementation Guidelines

Flow Consumption

  • Rule: ALWAYS use repeatOnLifecycle(Lifecycle.State.STARTED) to collect flows in Views.
  • Why: Prevents crashes (collecting while view destroyed) and saves resources (stops collecting in background).

LiveData vs Flow

  • New Code: Use StateFlow exclusively.
  • Legacy: If using LiveData, observe with viewLifecycleOwner (Fragment), NOT this.

Anti-Patterns

  • No launchWhenStarted/Resumed: Deprecated. Use repeatOnLifecycle instead.
  • No observe(this) in Fragments: Use viewLifecycleOwner to prevent lifecycle leaks.

References

Signals

GitHub stars
565
Forks
163
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
android-legacy-state
Source
github.com/hoangnguyen0403/agent-skills-standard