I had to delete the thread (setting it as null for the Garbage
Collector) and create another, restarting it.

I am avoiding the Exception, but now my animation is not resuming.

Hope this helps someone.

Cass



On May 24, 10:59 am, Cass Surek <[email protected]> wrote:
> Hello,
>
> I have based my code upon the LunarLander example and added a
> preferences Activity launched from a menu item.
>
> The preferences get loaded and displayed correctly, but when I press
> the return button my app fails with an exception IllegaThreadState as
> it tries to start the thread again from within the following method:
>
>     /*
>      * Callback invoked when the Surface has been created and is ready
> to be
>      * used.
>      */
>     public void surfaceCreated(SurfaceHolder holder) {
>         // start the thread here so that we don't busy-wait in run()
>         // waiting for the surface to be created
>         thread.setRunning(true);
>         thread.start();
>
>     }
>
> I have tried to check if the thread is running with thread.isAlive()
> ==false but it appears that when the activity loses focus the thread
> returns false for that call.
>
> Any suggestions on what I could do to prevent such exception? I've
> tried try/catch but I am unsure on what to call on the exception.
>
> Any help much appreciated,
>
> Cass Surek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to