Android AsyncTask inside AsyncTask

前端 未结 3 764
野趣味
野趣味 2020-12-18 05:44

So, I\'m working on a barcode decoder, which once we have the barcode goes to multiples API over the internet to decode what was just scanned. The thing is that I have to li

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 06:15

    I think it's absolutely legitimate to start the second AsyncTask in the onPostExecute of the first AsyncTask, Mixing both operations is a bad logical idea, As "The Offspring" said - "You've gotta keep 'em separated"

    If you don't want it to be directly inside the onPostExecute itself, set a handler to execute it in the activity and call this handler from onPostExecute.

    And last thing - If you have a lot of logic - move it to a separate file, don't keep it all at the same file.

提交回复
热议问题