views:

35

answers:

1

hello guys,

Can anybody tell me what method of an activity executes when an application closes?. like i have a main activity and if i press back button on my phone. The Application closes so i want to know what method executes at that time.

+1  A: 

The onPause() method should be called when your application is preparing to go into the background. In the case where you hit the back button, onStop() should also be called. However, it is not necessarily guaranteed that onStop() will be called in all situations (such as low memory situations) since an application may be killed to reclaim resources at any point after onPause() has returned.

See also: Activity Lifecycle.

eldarerathis