Thanks for the explanation. I've changed my code to use correctly the
asynctask and understood my errors.
It's working well but as you said, asynctask are not made to run
infinitely.

I'll change my code to use this postDelayed() method (romain guy also
told about this one on IRC).

Thanks a lot !

P.S: O'Reilly's book is not that clear :-)

On Oct 7, 6:29 pm, "Mark Murphy" <mmur...@commonsware.com> wrote:
> > Okay, I understand my error.
>
> > But now that I've modify my code with the process done by my
> > doInBackground method and the draw done by the onProgressUpdate, I
> > still don't have any change done on the gui. Debugging the
> > application, it seems that the method onProgressUpdate is never
> > called.
> > Here is the code:http://pastebin.com/m13f62a86
>
> Do not use AsyncTask for an indefinite amount of work. doInBackground()
> can run for a while, but it is not designed to run infinitely.
>
> In this case, if all you are seeking is one-second delays between updates
> of the game board, use postDelayed() (available on any View class, such as
> your TableLayout) to queue up a Runnable to be executed after 1000ms. Have
> that Runnable do its work to update the game board, then queue the
> Runnable itself again for another 1000ms delay. You can then drop the
> AsyncTask and all your background thread stuff.
>
> For the future, if you do use AsyncTask elsewhere, add @Override to
> doInBackground() and onProgressUpdate(). With AsyncTask, @Override is
> essential to help determine when you make mistakes with the data types.
> Also, if you are going to have doInBackground() return something
> (Boolean), you really should be consuming that data in onPostExecute(),
> which you did not override.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to