Question

In my simple android app I have 2 activities. In first activity(Main activity) I have override the ON STOP method. But when I go do the second activity on stop method of main_Activity is called. Why this happens? According to my understanding I should call on Pause rather then on Stop.

Was it helpful?

Solution

It calls both. onPause() will be called before onStop(), if onResume() was called. Rougly speaking, onPause() is called when activity is partially hidden, and onStop() when it is fully hidden.

Read up on http://developer.android.com/training/basics/activity-lifecycle/index.html to understand the Activity lifecycle.

OTHER TIPS

OnStop is called when FirstActivity calls SecondActivity and FirstActivity looses visibility. If Second Activity has a transparent background then the FirstActivity will be visible underneath, so not loosing visibility and onStop on FirstActivity will never be called.

onPause() - activity is paused.

onStop() - activity is stopped working but it is there in stack.

onDestroy() - activity is stopped and also has been removed from stack.

therefore When you go from one activity to another activity, it makes onPause() and onStop() but not onDestroy()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top