0

I have a game which has surfaceview and running on a thread. if I press HOME button when the game's playing and then I open the game again through the icon, I get a force close. what's the problem might be?

Fugogugo
  • 4,460
  • 10
  • 36
  • 50
  • 4
    Maybe android does not approve of your game. I dont know. Lets see the logs to see what android is complaining about ? – Reno Mar 10 '11 at 05:51

1 Answers1

9

Do you start your Thread by using thread.start() in the surfaceCreated callback? If so, there will always be an error if you're not using a member variable that contains a check if your game has been started.

You need to "pause" your Thread in the surfaceDestroyed callback using wait() command so it doesn't reiterate your game code during pause. Next time you're starting your application (for the first time or maybe second time) you need to start() it or notify() it (after pausing) depending on the circumstances.

At last, always always post code. That will engage people to answer the question properly and correct.

Wroclai
  • 26,835
  • 7
  • 76
  • 67
  • 1
    @Gaurav: Look here: http://stackoverflow.com/questions/5318847/android-crash-when-app-is-closed-and-reopened/5318902#5318902 – Wroclai Aug 28 '12 at 16:30