Fugogugo
Fugogugo

Reputation: 4480

Force Close when opening app after pressing home button

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?

Upvotes: 0

Views: 4676

Answers (1)

Wroclai
Wroclai

Reputation: 26925

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.

Upvotes: 9

Related Questions