android - Execute a function when all Async Http Requests are finished -



android - Execute a function when all Async Http Requests are finished -

let's have 2 http async calls, task 1 , task 2. , want execute both of them in same time. , 1 time both finished, want trigger function.

since don't know task finished first, how can know tasks finished , trigger function?

step-1 : create interface taskcomplete ,

public interface taskcomplete { public void taskdone(string asyncclassname); }

step-2 : create object of in class calling async task.

taskcomplete taskcomplete = new taskcomplete() { boolean firstdone = false; boolean seconddone = false; @override public void taskdone(string asyncclassname) { // todo auto-generated method stub if(asyncclassname.equals("first_async")) { firstdone = true; } else if(asyncclassname.equals("second_async")) { seconddone = true; } if(firstdone == true && seconddone == true) { // both async completed - work } } };

step-3 : phone call these respective onpostexecute method of async class.

taskcomplete.taskdone("first_async"); taskcomplete.taskdone("second_async");

android http android-asynctask

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -