Thanks for the reply Jeff.
I tried your approach. I set the while loop in the void run() method to false in the surfaceDestroyed() method to stop the thread. I called thread.interrupt and thread.join as well exactly as you described. When I close the program and reopen it, it gives me the FC error. Now this is because I am trying to restart a thread that has been terminated. I fixed that by saying in surfaceCreated() if the thread state = TERMINATED then create a new thread. This stops the FC error but the saved instance state is not loaded because onCreate() was never called. I cannot find another way to use the savedInstanceState except in the onCreate method. For some reason, being it a thread or surfaceview, once the thread is created it will not go back to onCreate. It only goes straight to surfaceCreated() because I guess the thread is still there, active or not. The only way to fix this problem is that when onSaveInstanceState() is called I kill the activity by calling finish(); This calls onCreate every time you reopen the game but the onSaveInstanceState data has been erased because you destroyed the activity. So my problem still stands. SurfaceCreated gets called and not onCreate when you re-open the program. I have no idea why this is happening. The only other way I can see is to save the setting/variables to a database of somesort and reload them somewhere in the thread... Thanks for your help but so far seems like a dead end... Right now I will just destroy the activity when it loses focus. Not an idea solution but it's the only one that works so far. On Apr 30, 7:08 pm, Jeff <[email protected]> wrote: > I don't know if this will help with your symptoms, but I'm just making > sure that thethreadgets interrupted and thethreadstops before the > surfaceDestroyed method returns. > > If you interrupt athread, thethreadneeds to expect the interrupt. > > assuming that you are extendingThread(untested code) > > public BallDropThread extendsThread{ > //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 thethreadshouldstop > try{ > thread.join(); //make thisthreadwait for the > otherthreadto > finish before returning > }catch(InterruptedException ie){ > //handle the case if thethread.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 thethreadbut SurfaceCreated still > > gets called first. > > > Is there a way to call onCreate from SurfaceCreated? > > > Another solution I tried to just set thethreadto a paused state (ie. > > setRunnable(false) ), and when the app restarts simply > > setRunnable(true) to run thethreadagain, 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 athread. > > > >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 > 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

