I’m using an IntentService to perform background tasks, such as updating data from a remote server.
In some cases, the same request can be queued multiple times by the user, but I only want to execute it once (there’s no point in updating the data from the server twice in a row).
Is there a simple way to do this using an IntentService, or should I just use a standard Service?
Unfortunately, no. The
Handlerqueue used by theIntentServiceis not visible through the SDK and does not have public methods to let you inspect its contents, anyway.Probably. You could try to keep your own parallel copy of the work queue, flagging duplicates and ignoring them in your
onHandleIntent(), but making sure you are always in sync with the real internal queue might get icky.