asynctask-to-executor

Installation
SKILL.md

Migrating AsyncTask to ExecutorService / WorkManager

Instructions

AsyncTask has been deprecated since API 30. It leaks Activities, serializes tasks globally on older devices, and has no structured cancellation. Replace it with either a scoped ExecutorService + Handler or WorkManager depending on the use case.

1. Decision Tree

  • Short-lived, tied to a screen (load, parse, save on click) → ExecutorService + ViewModel.
  • Deferrable, must run even if the app dies (upload, sync) → WorkManager.
  • Reactive pipeline with cancellation-on-recycle → RxJava 3 (see rxjava3 skill).

2. Pattern: In-Activity AsyncTask

Before:

Installs
1
GitHub Stars
1
First Seen
Jul 10, 2026
asynctask-to-executor — almasumdev/awesome-java-android-agent-skills