when onStop is actually called
Asked Answered
M

3

5

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.

Mead answered 17/4, 2014 at 17:33 Comment(0)
B
5

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.

Bacon answered 17/4, 2014 at 17:37 Comment(0)
B
2

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.

Berky answered 24/12, 2021 at 11:30 Comment(0)
B
1

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()

Baccate answered 17/4, 2014 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.