Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity is getting destroyed while pressing the home button

In my application, when I press the home button the activity is going to onDestroy(). It suppose to be called onPause() method only right?

Why it is happening so?

like image 456
Kamalone Avatar asked Jan 14 '13 06:01

Kamalone


People also ask

What happens to activity when home button is pressed?

As we press Home button then first Activity goes in onPause() then onStop().

Does Pressing Home button close app?

Some applications will continue to run as a background application, so pressing the home button will not kill them (e.g., Google Play Music will still play after pressing the home button). Your friend might be concerned that by pressing the home button you did not exit the program, and therefore it is still running.

What happens when an activity is destroyed Android?

When Android creates and destroys an activity, the activity moves from being launched to running to being destroyed. An activity is running when it's in the foreground of the screen. onCreate() gets called when the activity is first created, and it's where you do your normal activity setup.


1 Answers

also check that you don't use the android:noHistory flag in your manifest for the Activity

documentation: android:noHistory Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it's no longer visible on screen

like image 144
Alexis Contour Avatar answered Oct 05 '22 06:10

Alexis Contour