본문으로 건너뛰기
cccskills
무료GitHub에 공개

android-background-task-specialist

Android background task specialist for WorkManager, Foreground Services, Doze mode, and battery optimization. Activate on: WorkManager, background task Android, Foreground Service, Doze mode, battery optimization, periodic work, background sync Android, JobScheduler. NOT for: iOS background tasks (use swiftui-data-flow-expert), React Native background (use mobile-offline-sync-architect), UI architecture (use jetpack-compose-navigation-expert).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Android Background Task Specialist

Expert in Android background execution with WorkManager, Foreground Services, Doze mode handling, and battery-efficient processing.

Activation Triggers

Activate on: "WorkManager", "background task Android", "Foreground Service", "Doze mode", "battery optimization", "periodic work", "background sync", "JobScheduler", "background processing Android"

NOT for: iOS background tasks → swiftui-data-flow-expert | React Native background → mobile-offline-sync-architect | UI architecture → jetpack-compose-navigation-expert

Quick Start

  1. Choose the right API — WorkManager for deferrable work, Foreground Service for user-visible ongoing tasks, coroutines for short async work
  2. Define workers — extend CoroutineWorker with suspend functions for clean async code
  3. Configure constraints — network type, battery level, storage requirements
  4. Handle Doze and App Standby — use WorkManager (not AlarmManager) for Doze-compatible scheduling
  5. Test with adb — force Doze mode and verify work executes when constraints are met

Core Capabilities

DomainTechnologies
Deferrable WorkWorkManager 2.10, OneTimeWorkRequest, PeriodicWorkRequest
ForegroundForeground Service types (dataSync, location, mediaPlayback, shortService)
ConstraintsNetworkType, BatteryNotLow, StorageNotLow, DeviceIdle
ChainingWorkContinuation, parallel chains, unique work policies
TestingTestWorkerBuilder, TestListenableWorkerBuilder, WorkManagerTestInitHelper

Architecture Patterns

WorkManager Decision Tree

Is the task user-initiated and needs to complete?
  ├─ YES → Is it short (< 10 min)?
  │   ├─ YES → Foreground Service (shortService type)
  │   └─ NO → Foreground Service (dataSync, location, etc.)
  │
  └─ NO → Is it deferrable?
      ├─ YES → WorkManager
      │   ├─ One-time? → OneTimeWorkRequest
      │   └─ Periodic? → PeriodicWorkRequest (min 15 min interval)
      │
      └─ NO → Is it while app is visible?
          ├─ YES → CoroutineScope (viewModelScope or lifecycleScope)
          └─ NO → You probably need WorkManager anyway

CoroutineWorker with Retry and Progress

@HiltWorker
class SyncWorker @AssistedInject constructor(
    @Assisted context: Context,
    @Assisted params: WorkerParameters,
    private val syncRepository: SyncRepository,
    private val notificationHelper: NotificationHelper,
) : CoroutineWorker(context, params) {

    override suspend fun doWork(): Result {
        // Report progress for UI observation
        setProgress(workDataOf("progress" to 0))

        return try {
            val pendingItems = syncRepository.getPendingChanges()

            pendingItems.forEachIndexed { index, item ->
                syncRepository.syncItem(item)
                setProgress(workDataOf(
                    "progress" to ((index + 1) * 100 / pendingItems.size)
                ))
            }

            Result.success(workDataOf("synced" to pendingItems.size))
        } catch (e: IOException) {
            if (runAttemptCount < 3) {
                Result.retry()  // Exponential backoff by default
            } else {
                Result.failure(workDataOf("error" to e.message))
            }
        }
    }

    override suspend fun getForegroundInfo(): ForegroundInfo {
        return ForegroundInfo(
            NOTIFICATION_ID,
            notificationHelper.createSyncNotification()
        )
    }
}

Scheduling with Constraints and Chaining

// Schedule periodic sync every 1 hour (minimum 15 min)
val syncRequest = PeriodicWorkRequestBuilder<SyncWorker>(1, TimeUnit.HOURS)
    .setConstraints(
        Constraints.Builder()
            .setRequiredNetworkType(NetworkType.CONNECTED)
            .setRequiresBatteryNotLow(true)
            .build()
    )
    .setBackoffCriteria(
        BackoffPolicy.EXPONENTIAL,
        WorkRequest.MIN_BACKOFF_MILLIS,
        TimeUnit.MILLISECONDS
    )
    .addTag("sync")
    .build()

WorkManager.getInstance(context).enqueueUniquePeriodicWork(
    "periodic-sync",
    ExistingPeriodicWorkPolicy.KEEP,  // Don't restart if already scheduled
    syncRequest
)

// Chain: download → process → upload (sequential)
WorkManager.getInstance(context)
    .beginWith(downloadWork)
    .then(processWork)
    .then(uploadWork)
    .enqueue()

Anti-Patterns

  1. AlarmManager for deferrable work — AlarmManager alarms are not Doze-compatible and drain battery. Use WorkManager which respects Doze, App Standby, and battery saver.
  2. Background Service without foreground notification — Android 12+ kills background services. Use Foreground Service with proper type declaration or WorkManager.
  3. PeriodicWork under 15 minutes — WorkManager enforces a minimum 15-minute interval. For more frequent work, use Foreground Service or coroutine with lifecycle awareness.
  4. Not declaring foreground service type — Android 14+ requires explicit foregroundServiceType in manifest. Omitting it causes SecurityException.
  5. Ignoring work observation — starting work but not showing progress to users. Observe WorkInfo via getWorkInfoByIdLiveData() or getWorkInfoByIdFlow() to update UI.

Quality Checklist

[ ] WorkManager used for deferrable background tasks (not AlarmManager)
[ ] Foreground Service declared with correct type in AndroidManifest
[ ] Constraints configured (network, battery, storage)
[ ] Retry policy with backoff for transient failures
[ ] Unique work policy set for periodic/one-time work
[ ] Work progress observable from UI
[ ] Doze mode tested via adb: `adb shell dumpsys deviceidle force-idle`
[ ] Battery optimization tested: `adb shell am set-inactive <package> true`
[ ] Workers tested with TestWorkerBuilder
[ ] Notification channels created for foreground service notifications
[ ] Work chains handle partial failure gracefully
[ ] Background work respects user's battery saver preference

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Use for insight, reframing, contradiction, impasse, and anomaly-driven problem solving when execution effort no longer helps. NOT for routine optimization, error correction, or well-specified tasks with known solution paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Apply cognitive task analysis to expert work that depends on perceptual cues, branching judgment, and recurring monitoring loops. Use when decomposing expert capability into agent structure, simulation design, or validation interviews. NOT for ordinary step-by-step SOP capture or simple pipelines with no tacit cue layer.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

curiositech의 스킬 모두 보기

이 스킬의 문제 신고