You cannot execute the same AsyncTask
more than once. You'll have to instantiate it before executing it each time, e.g.:
myTask = new myTask();
myTask.execute(context, s);
Of course you can then remove the initialization at the beginning.
For stopping and restarting, use:
myTaks.cancel(true);
myTask = new myTask();
myTask.execute(context, s);
Even though you cancel the AsyncTask
, you cannot use it again.