원클릭으로
android-background-execution
Expert guidance on implementing and managing background tasks in modern Android applications (API 30+).
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Expert guidance on implementing and managing background tasks in modern Android applications (API 30+).
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Handling Bluetooth Low Energy, flow wrappers, and Android 12+ permissions.
Seamless integration of CameraX with Google ML Kit for vision tasks.
Deep-dive skills for banking and healthcare apps.
Use when integrating Google Gemini Nano via AICore for on-device ML.
Automated UIAutomator tests and Hardware mocking setup.
Expanding KMP shared UI to cover Compose Multiplatform edge-cases.
| name | android-background-execution |
| description | Expert guidance on implementing and managing background tasks in modern Android applications (API 30+). |
This skill provides a structured approach to implementing background work in Android, ensuring high performance, battery efficiency, and compliance with modern system restrictions (API 30 and above).
Use for persistent, deferrable work that must execute even if the app exits or the device restarts.
setExpedited(true)).Use for immediate, user-visible work that is the primary focus of the app (e.g., Music Player, Step Tracker).
foregroundServiceType in the manifest.AlarmManager)Use for exact, time-based scheduling.
setExactAndAllowWhileIdle() is for high-precision needs (e.g., clocks).| Requirement | Recommended Tool |
|---|---|
| Deferrable, restart-resilient | WorkManager (OneTime/Periodic) |
| Immediate, continues when app is closed | WorkManager (Expedited) |
| User-visible, real-time | Foreground Service |
| Specific clock time (e.g. 8:00 AM) | AlarmManager |
class SyncWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {
override suspend fun doWork(): Result {
return try {
// Background logic here
Result.success()
} catch (e: Exception) {
if (runAttemptCount < 3) Result.retry() else Result.failure()
}
}
}
// Enqueueing
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiresBatteryNotLow(true)
.build()
val syncRequest = OneTimeWorkRequestBuilder<SyncWorker>()
.setConstraints(constraints)
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 1, TimeUnit.MINUTES)
.build()
WorkManager.getInstance(context).enqueue(syncRequest)
<service
android:name=".MyService"
android:foregroundServiceType="dataSync" />
class MyService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notification = NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Syncing Data")
.setSmallIcon(R.drawable.ic_sync)
.build()
ServiceCompat.startForeground(this, 1, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
// logic...
return START_NOT_STICKY
}
}
WorkManager handles this automatically by batching requests.setExpedited(true). Note that this has quotas.Constraints in WorkManager to prevent unnecessary wakeups when offline.WorkManagerTestInitHelper for testing workers in unit/integration tests without waiting for real-world constraints.com.example.app.data.worker or com.example.app.ui.background.com.example.app.service.Repository classes, not inside Worker or Service classes.