java - How to avoid chaining several AsyncTask calls? -


i have make several calls web service, each step uses values previous step, right have huge chain of asynctasks: each asynctask executed in onpostexecute() of asynctask of previous step. very ugly, , hard modify. how can avoid this? put each step in separate function:

int step5() //this function on main ui thread {    return getstep5valuesfromwebservice() + valuesfromprevioussteps; }  int getstep5valuesfromwebservice() {    //do work on new thread    //getvaluefromservice(); <-- function returns int web service, has called thread } 

how call getvaluefromservice() step5() function returns value calculated in getvaluefromservice() function?

can not do:

private class myasync extends asynctask<string, integer, long> {      protected long doinbackground(string... symbols) {         step1();         step2();         step3();         step4();         step5();     }      private void step1(){}     private void step2(){}     private void step3(){}     private void step4(){}     private void step5(){}      protected void onprogressupdate(integer... progress) {     }      protected void onpostexecute(long result) {     } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -