Every time I do a httpRequest
, the screen will appear to be locked up for a few seconds while the code is executing. Hence I used AsyncTask
to do all my httpRequest
stuff in a separate thread while putting up a ProgressDialog
so the user knows something is happening.
I recently encountered the following situation: the input of one of my httpRequest
is dependent on the result from a previous httpRequest
(+parse) action. I can't just put the two AsyncTask
s sequentially cause Android will put them in two threads and start the second one without the first one being finished. And without an appropriate input (the result of the first httpRequest
), my second httpRequest
will crash the app.
Is there way I can put-in a wait()
to force the second AsyncTask
not to start until the first one finishes?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…