M
M
MdaUZH2016-08-29 10:15:07
Android
MdaUZH, 2016-08-29 10:15:07

Why doesn't AsyncTask slow down?

Hello everyone, there is an AsyncTask with a cycle ...
After a certain user action, AsyncTask needs to be stopped and restarted ..
I do it like this:

Останавливаю цикл который в doInBackground()

Далее делаю в методе stop (создал его в AT)
this.cancel(true)

But when I try to start the same AsyncTask again, I get an error that the task is already running.
How can I stop it so that I can restart it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-08-29
@MdaUZH

as if AysncTask has 1 problem, it can be used only 1 time, that is, after you stop it, you need to create a new instance of your AsyncTask and start it again, you can override the onForceStop method in my opinion, and pass it to another class all the elements that are needed, and then create a new instance of the class and pass data to the new asynctask and run it again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question