You can execute an AsyncTask instance only once. You are actually creating two instances, but you should call it so that it is never called:
new DownloadWebPageTask().execute(new String[] { "http://yahoo.com" }); new DownloadWebPageTask().execute(new String[] { "http://google.com" });
instead of this:
DownloadWebPageTask task = new DownloadWebPageTask(); task.execute(new String[] { "http://google.com" });
I think you ran into a problem here:
private void EndA() { Debug("EndA()"); StartB(); }
Your value for g_GetWhat changes as soon as StartB begins. Therefore, when execution returns from EndA() , the following if statement evaluates to true, since the value of g_GetWhat has changed.
if(g_GetWhat == 1) { EndA(); } if(g_GetWhat == 2) { EndB(); }
The value of g_GetWhat is actually 2, so you see the result you see. You must pass g_GetWhat to your AsyncTask when you call it, and make it a task instance variable.
source share