Force Close when opening app after pressing home button

前端 未结 1 730
孤独总比滥情好
孤独总比滥情好 2021-01-17 02:48

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 c

相关标签:
1条回答
  • 2021-01-17 03:31

    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.

    0 讨论(0)
提交回复
热议问题