i want to run a Background ASycTask every few minutes. I created a timer and i execute the .execute command of the Background Task. I also created a bool isChecking which is true while the BackgroundNotify is running. The problem is that i still get the following error:
01-26 15:09:32.871: E/AndroidRuntime(22332): FATAL EXCEPTION: Timer-0
01-26 15:09:32.871: E/AndroidRuntime(22332): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)
01-26 15:09:32.871: E/AndroidRuntime(22332): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:578)
01-26 15:09:32.871: E/AndroidRuntime(22332): at android.os.AsyncTask.execute(AsyncTask.java:534)
01-26 15:09:32.871: E/AndroidRuntime(22332): at de.tecfriends.vbtsplash2013.MainActivity$2.run(MainActivity.java:61)
01-26 15:09:32.871: E/AndroidRuntime(22332): at java.util.Timer$TimerImpl.run(Timer.java:284)
What am i doing wrong?
An AsyncTask can only be executed once. If you need to execute the task again, create a new instance, and call
execute()on that: