Saturday, March 19, 2011

Show Dialog with onBackPressed and onPause method

onPause method in Android activity is for saving the UI state data, when onPause is called, the OS already puts the current activity in background and starts to render the target activity. So no any UI related operation (for example, showing a dialog box, etc.) should be put into onPause method.

If there is a need to do UI related operation, like prompting user to save the pending change or cancel the current operation, then those UI related operation should be put into menu handler or onBackPressed method.

No comments:

Post a Comment