Consider this: I’ve got Activity, in onCreate() I start AsyncTask to load its content. I’ve followed this sample. Now my problem is: I want to download file in that Activity, using AsyncTask. But I don’t know how to make existing AsyncTask do various tasks.
If anyone had the same problem, I would appreciate your help.
Consider this: I’ve got Activity, in onCreate() I start AsyncTask to load its content.
Share
Well, I’ve succeeded to make it call again and again… you have to instantiate your class as a null first (int the Activity).
and then put it in a try… catch block:
The other thing you’re interrested about is the differenc methods you want to run… Well, I wanted to do the same, but I’ve had no time writing that one, but I’ve thought about it on the way home from work.
I think your class extending AsyncTask should look like this:
create some variables or ArrayLists in your AsyncTask, and do the decision on the overriden onPreExecute() method where you have to make a switch, or some if’s. Do the call/work on the overriden doInBackground(), get the result, and process it in the overriden onPostExecute() method.
I don’t know if this line works, since I’ve had no time to experiment it, I really just thought about it, how to… 🙂
But I hope the thought helps at least! 🙂