Panthersgba
Newbie
Hey guys,
I have been working on a game, but I can't seem to get it to reopen where it leaves off if you hit the home button. I don't know how I need to set up the onCreate and stuff. I had put in a few things, but it keeps force closing when I try to open it back up and gives me this logcat
E/AndroidRuntime( 183): Uncaught handler: thread main exiting due to uncaught e xception E/AndroidRuntime( 183): java.lang.IllegalThreadStateException: Thread already s tarted. E/AndroidRuntime( 183): at java.lang.Thread.start(Thread.java:1286) E/AndroidRuntime( 183): at com.Waldev.cannon.CannonBlast$panel.surfaceCr eated(CannonBlast.java:515) E/AndroidRuntime( 183): at android.view.SurfaceView.updateWindow(Surface View.java:392) E/AndroidRuntime( 183): at android.view.SurfaceView.onWindowVisibilityCh anged(SurfaceView.java:182) E/AndroidRuntime( 183): at android.view.View.dispatchWindowVisibilityCha nged(View.java:3745) E/AndroidRuntime( 183): at android.view.ViewGroup.dispatchWindowVisibili tyChanged(ViewGroup.java:690) E/AndroidRuntime( 183): at android.view.ViewGroup.dispatchWindowVisibili tyChanged(ViewGroup.java:690) E/AndroidRuntime( 183): at android.view.ViewRoot.performTraversals(ViewR oot.java:694) E/AndroidRuntime( 183): at android.view.ViewRoot.handleMessage(ViewRoot. java:1613) E/AndroidRuntime( 183): at android.os.Handler.dispatchMessage(Handler.ja va:99) E/AndroidRuntime( 183): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 183): at android.app.ActivityThread.main(ActivityThrea d.java:4203) E/AndroidRuntime( 183): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 183): at java.lang.reflect.Method.invoke(Method.java:5 21) E/AndroidRuntime( 183): at com.android.internal.os.ZygoteInit$MethodAndA rgsCaller.run(ZygoteInit.java:791) E/AndroidRuntime( 183): at com.android.internal.os.ZygoteInit.main(Zygot eInit.java:549) E/AndroidRuntime( 183): at dalvik.system.NativeStart.main(Native Method)
I am not sure exactly what to do with what I have to make it work, I just know that the thread is still running and I need to keep surfaceCreated from going I guess. Here are my onCreate and surface stuff
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode == KeyEvent.KEYCODE_MENU){
if(panelStuffz.getState() != -11){
panelStuffz.setPreviousState(panelStuffz.getState());
panelStuffz.setState(-11);
return true;
}
if(panelStuffz.getState() == -11){
panelStuffz.setState(panelStuffz.getPreviousState());
}
}
return false;
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.start();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// simply copied from sample application LunarLander:
// we have to tell thread to shut down & wait for it to finish, or else
// it might touch the Surface after we return and explode
boolean retry = true;
thread.setRunning(false);
while (retry) {
try {
thread.join();
retry = false;
} catch (InterruptedException e) {
// we will try it again and again...
}
}
}
any ideas? My friends and I have been stumped : /
I have been working on a game, but I can't seem to get it to reopen where it leaves off if you hit the home button. I don't know how I need to set up the onCreate and stuff. I had put in a few things, but it keeps force closing when I try to open it back up and gives me this logcat
E/AndroidRuntime( 183): Uncaught handler: thread main exiting due to uncaught e xception E/AndroidRuntime( 183): java.lang.IllegalThreadStateException: Thread already s tarted. E/AndroidRuntime( 183): at java.lang.Thread.start(Thread.java:1286) E/AndroidRuntime( 183): at com.Waldev.cannon.CannonBlast$panel.surfaceCr eated(CannonBlast.java:515) E/AndroidRuntime( 183): at android.view.SurfaceView.updateWindow(Surface View.java:392) E/AndroidRuntime( 183): at android.view.SurfaceView.onWindowVisibilityCh anged(SurfaceView.java:182) E/AndroidRuntime( 183): at android.view.View.dispatchWindowVisibilityCha nged(View.java:3745) E/AndroidRuntime( 183): at android.view.ViewGroup.dispatchWindowVisibili tyChanged(ViewGroup.java:690) E/AndroidRuntime( 183): at android.view.ViewGroup.dispatchWindowVisibili tyChanged(ViewGroup.java:690) E/AndroidRuntime( 183): at android.view.ViewRoot.performTraversals(ViewR oot.java:694) E/AndroidRuntime( 183): at android.view.ViewRoot.handleMessage(ViewRoot. java:1613) E/AndroidRuntime( 183): at android.os.Handler.dispatchMessage(Handler.ja va:99) E/AndroidRuntime( 183): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 183): at android.app.ActivityThread.main(ActivityThrea d.java:4203) E/AndroidRuntime( 183): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 183): at java.lang.reflect.Method.invoke(Method.java:5 21) E/AndroidRuntime( 183): at com.android.internal.os.ZygoteInit$MethodAndA rgsCaller.run(ZygoteInit.java:791) E/AndroidRuntime( 183): at com.android.internal.os.ZygoteInit.main(Zygot eInit.java:549) E/AndroidRuntime( 183): at dalvik.system.NativeStart.main(Native Method)
I am not sure exactly what to do with what I have to make it work, I just know that the thread is still running and I need to keep surfaceCreated from going I guess. Here are my onCreate and surface stuff
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode == KeyEvent.KEYCODE_MENU){
if(panelStuffz.getState() != -11){
panelStuffz.setPreviousState(panelStuffz.getState());
panelStuffz.setState(-11);
return true;
}
if(panelStuffz.getState() == -11){
panelStuffz.setState(panelStuffz.getPreviousState());
}
}
return false;
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.start();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// simply copied from sample application LunarLander:
// we have to tell thread to shut down & wait for it to finish, or else
// it might touch the Surface after we return and explode
boolean retry = true;
thread.setRunning(false);
while (retry) {
try {
thread.join();
retry = false;
} catch (InterruptedException e) {
// we will try it again and again...
}
}
}
any ideas? My friends and I have been stumped : /