I use an asynctask in my app that downloads some data from the internet. If this task is executed twice within seconds, user presses the button twice, I get an IllegalState error saying a task can not be execute twice. If the user waits about 30 seconds, everyting is fine.
Then I tried to use AsyncTask.getStatus(), like this, to only execute when the task was NOT RUNNING, ie executed when status was PENDING or FINISHED, but this only worked the first time when the getStatus() was PENDING. If it was FINISHED, the same IllegalState error was produced.
Then I tried to follow an other example, saying the a new object of the AsyncTask should be created each time it is supposed to be executed. This seems to work.
So my question is, is it not possible to use one instance of an asynctask object and reexecute it? If so, how come it can be done if you wait long enought (like 30 seconds)?