Is there any way within Android to schedule sequential services, similar to sending ordered broadcasts for BroadcastReceivers
? What I mean is that I'm looking for something where I can start service A. Once service A completes, start service B. However, this gets a little more complicated because service A won't always need to be started, only sometimes.
More specifically, I have an activity that allows users to search for content. In order for me to make an HTML request (using Retrofit) once the user enters a query, I need to supply an access token. The access token is only valid for an hour. However, if a user makes another search request within that hour, there's no need for a new access token. Here's a quick logic diagram:
I've looked at JobScheduler
and JobDispatcher
, as well as Android-Job from Evernote. However, they all appear to do the same great things: start services when certain constraints are met. However, I couldn't find anything about handling multiple requests, specifically where one request is dependent on another.
Would anyone be able to provide some insight into this? I've thought about doing this with BroadcastReceivers
as well, but couldn't think of anything that'd be a robust solution. Any help on this would be greatly appreciated! :)