I thought when we press home button where ever you are your onPause() and onStop() will be called. But I'm not completely sure. Please give me some more info.

- 8,084
- 8
- 48
- 62

- 195
- 1
- 15
-
onPause() is called when Home button is pressed. Also, home button can't be overrided. It just sends all the applications to the background and opens the main screen of phone. – berserk Jul 10 '14 at 07:36
-
Is our activity is stoped when we press home button? – Nava2011 Jul 10 '14 at 07:37
-
It won't stop. Home will just call onPause as it is sending app to background. It depends on the onPause function of app. – berserk Jul 10 '14 at 07:38
-
2No Onpause and OnStop Both are calling just now i tried the sample. – android_dev Jul 10 '14 at 08:03
2 Answers
Normally, you press the home button onpause and onStop is called. But if your activity has parameter's like android:noHistory="true" it will cause your activity's onDestroy to be called. Though I am not sure there may be similar scenario's for properties in android:launchMode.

- 10,090
- 2
- 44
- 61
Basically the main difference between onPause and onStop is that onPause is called when the activity about to enter the stage where it is partially obscured.(onStop - fully obscured) When you click your home button, you are about to enter a stage where the activity is fully obscured. But to enter that stage, you would have had to already gone through the stage where the activity is partially obscured(why onPause is also called). Thats why onPause is always called before onStop. (transition from partially obscured to fully obscured)

- 8,711
- 14
- 71
- 126
-
Okay then both two methods are executed right.I told the same thing. But @berserk told it is not stoped. So i didn't get clarity. – Nava2011 Jul 10 '14 at 07:53
-
it will stop. override it and do a log.d inside the onstop to see if its called(will be) – committedandroider Jul 10 '14 at 07:54
-
I just gave an answer that i think would be more satisfying – committedandroider Jul 10 '14 at 07:55