Reputation: 14840
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?
Upvotes: 1
Views: 1848
Reputation: 1006574
Is there a simple way to do this using an IntentService
Unfortunately, no. The Handler
queue used by the IntentService
is not visible through the SDK and does not have public methods to let you inspect its contents, anyway.
should I just use a standard Service?
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.
Upvotes: 1