I can successfully call activity.onPause() to pause the application. But when i call activity.onResume() the application restarts.
Is there a way to avoid this ?
Edited
I actually want to pause my application using a pause button
I can successfully call activity.onPause() to pause the application. But when i call activity.onResume() the application restarts.
Is there a way to avoid this ?
Edited
I actually want to pause my application using a pause button
You should never call methods of the
Activity
life cycle by yourself! So no call toonPause()
onResume()
onDestroy()
onCreate()
onStop()
oronStart()
.Edit to fit your edited question:
You should pause your game, not the Activity. You must have a thread where you work your game logic. That thread needs to be paused, not the game. So consider working on a pause logic there.
see Activity life cycle like as
under stood this method and You should save activity state and than resume it.
As I can guess no there isn't. All activites are using following flow: http://developer.android.com/images/activity_lifecycle.png
You should save activity state and than resume it.
And as mentioned above you shouldn't call it yourself... just override/implement it and let Android do the job.