I don't know if this will help with your symptoms, but I'm just making
sure that the thread gets interrupted and the thread stops before the
surfaceDestroyed method returns.

If you interrupt a thread, the thread needs to expect the interrupt.

assuming that you are extending Thread (untested code)

        public BallDropThread extends Thread{
                //override run
                public void run(){
                        while(!this.interrupted()){
                                //stuff to do
                        }
                }
        }
//then your surface destroy can look like this

        public void surfaceDestroyed(SurfaceHolder holder) {
                thread.interrupt(); //says that the thread should stop
                try{
                        thread.join(); //make this thread wait for the other 
thread to
finish before returning
                }catch(InterruptedException ie){
                        //handle the case if the thread.join is interrupt
                        //don't know if this will ever happen, if it can... 
throw a runtime
exception?, or reinterrupt?
                        Thread.currentThread().interrupt(); //reinterrupt 
because thrown
exception cleared interrupt and hope it's handled elsewhere
                }
        }

hope it helps
-Jeff

On Apr 30, 3:39 pm, "Cameron.M.Johnson" <[email protected]>
wrote:
> The problem I am continuing to have is that SurfaceCreated gets called
> instead of onCreate when the app restarts. I was using the join()
> method which I thought terminates the thread but SurfaceCreated still
> gets called first.
>
> Is there a way to call onCreate from SurfaceCreated?
>
> Another solution I tried to just set the thread to a paused state (ie.
> setRunnable(false) ), and when the app restarts simply
> setRunnable(true) to run the thread again, but all I get is a black
> screen when I do this... All the settings, variables and graphics are
> loaded but nothing happens.
>
> On Apr 29, 10:51 pm, Anurag Singh <[email protected]> wrote:
>
> > You can use Interrupt to strop a thread.
>
> >http://java.sun.com/docs/books/tutorial/essential/concurrency/interru...
>
> > - Anurag Singh
>
> > On Fri, Apr 30, 2010 at 3:57 AM, Cameron.M.Johnson <
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" 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 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to