Building responsive apps with IntentService
The IntentService
class is a specialized subclass of Service
that implements a background work queue using a single HandlerThread
. When work is submitted to an IntentService
, it is queued for processing by a HandlerThread
, and processed in order of submission.
If the user exits the app before the queued work is completely processed, the IntentService will continue working in the background. When the IntentService has no more work in its queue, it will stop itself to avoid consuming unnecessary resources.
The system may still kill a background app with an active IntentService, if it really needs to (to reclaim enough memory to run the current foreground process), but it will kill lower priority processes first, for example, other non-foreground apps that do not have active services.
The IntentService
class gets its name from the way in which we submit work to it: by invoking startService
with an Intent.
startService(new Intent(context, MyIntentService...