3

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Nava2011
  • 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
  • 2
    No Onpause and OnStop Both are calling just now i tried the sample. – android_dev Jul 10 '14 at 08:03

2 Answers2

4

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.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
1

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)

committedandroider
  • 8,711
  • 14
  • 71
  • 126