In my case, I am needing to obtain some data from the network, process it and then get other data from the network based on the result of the first network query.
However, the first query could produce the need for user intervention … or not.
I understand how AsyncTask can run and then display it’s result in a UI object.
However, how should I “chain” actions together so that the first AsyncTask derived object correctly dies before starting a new action.
My thought is that when onPostExecute is called, if I start another UI based action, it will not terminate until the UI based action has terminated.
Is there a correct way to finish an AsyncTask process, signal the result to the calling object, clean up, calling object can then do its own processing ?
Or am I fussing about nothing here ?
EDIT : Please note my question is about AsyncTask background processing and how to correctly use it to avoid an execution stack overflow. I am not asking if I should use this method.
The best way to do this I found, after a good amount of searching, is to use message handlers.
This means that, at the end of the threads action it posts a message with the result to the UI code (not a UI widget note) and then can terminate cleanly.
This means a light and simple implementation.