Skip to content
Back to skills

Android Legacy State

ASecurity

Integrate ViewModel state with Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity.

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added June 6, 2026
development

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned June 6, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-legacy-state --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Legacy State?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Legacy State
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-android-legacy-state/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-legacy-state)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: android-legacy-state
description: Integrate ViewModel state with Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity.
metadata:
  triggers:
    files:
    - '**/*Fragment.kt'
    - '**/*Activity.kt'
    keywords:
    - repeatOnLifecycle
    - launchWhenStarted
---
# Android Legacy State Standards

## **Priority: P1**

## 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

- [Flow Consumption Template](references/implementation.md)

Files in this skill

  • SKILL.md1.1 KB
  • evals/evals.json2.7 KB
  • references/implementation.md656 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.