rashmi ranjan
rashmi ranjan

Reputation: 388

how to manage jobs in job queue in android?

I am working on JOB queue. Here the scenario is i am storing 3 api calls in job queue. The first API is having more information in json. but last two is having less information. According to the priority when network is available it is calling those apis one bye one in right order. but as the first api is having more information it is taking more time to hit the server so it is reaching the server at last. Is there any way where after hitting the server we can able to run the rest APIs?

Upvotes: 1

Views: 561

Answers (1)

Nikhil Sharma
Nikhil Sharma

Reputation: 603

To manage your network request one after other you can Use AsyncTask. AsyncTask have 3 main method i.e

1)onPreExecute - can perform any Ui update while calling network request.

2)doInBackground - which run in background thread not on main thread.

3)onPostExecute - after doinbackground process onPostExecute will call.

like this you can call your request when first request get completed ,So on first onPostExecute , call second request and so On.

I hope like this you can manage your network request in serial way. Thanks :)

Upvotes: 1

Related Questions