I have a number of AsyncTask
set up as individual classes. I reuse them throughout my app. I wonder, in places where the same AsyncTask
may be needed more than one is it possible to use one instance of that custom AsyncTask
class multiple times? This is really a cosmetic problem since it bothers me having redundant sections of code, especially when an AsyncTask
uses a callback to communicate with it's starting activity.
I've tried to do it this way -
MyTask task = new MyTask(new someCallBackListener){
@Override
public void taskDone(boolean youDone){
}
});
And then in my activity just calling
task.execute(params);
This seems to work the first time, but I cannot execute it more than once. Do I really just need to initialize a new task each time I want to use it?