AgentSkillsCN

concurrency-android

Android 并发与后台任务:协程/调度器、结构化并发、WorkManager 与 Service/前台服务的对比,以及操作系统对并发执行的限制。在修改 Android 应用代码或后台处理逻辑时务必参考此指南。

SKILL.md
--- frontmatter
name: concurrency-android
description: "Android concurrency & background work: coroutines/dispatchers, structured concurrency, WorkManager vs Services/Foreground services, and OS execution limits. Use when modifying Android app code or background processing."
metadata:
  short-description: Android concurrency and background work

Purpose

Keep UI responsive and background work reliable under Android platform constraints.

When to use

Use this skill when touching:

  • Kotlin coroutines, flows, or dispatchers
  • Service / WorkManager / JobScheduler
  • long-running or background work

How to use

  1. Open references/concurrency-android.md.
  2. Decide: in-process coroutine vs WorkManager vs Foreground Service. Justify with constraints.
  3. Enforce structured concurrency and cancellation paths.
  4. Define failure handling and retries (idempotency).
  5. Define observability (log correlation IDs; metrics for queue/latency).
  6. Define verification (unit tests + instrumentation tests if needed; background restrictions).

Output expectation

  • Add an Android Background Work Choice section to the Concurrency Plan.