I run my android app, and when I press home button and come back to the app. Everything is maintained (the score, the state ..etc). assume it goes to OnPause the OnResume.
However, when I get a phone call while running my app, then my app state is reset (score is gone ..etc).
Why is that? Shouldn’t it go through the onPause/OnResume as well?
When you get a phone call, it does go through
onPauseandonStopand when it is brought to the front again it goes throughonStartandonResume. It may also be going throughonDestroywhich will cause it to go throughonCreatewhen you bring it back. Suggest puttingLogstatements in each of the lifecycle methods to see which are getting called (or breakpoints in the debugger). Then you’ll know what approach to take to resume your game.In reality, you should implement the app such that it can go through
onDestroyand recover when starting up again in the way you want.