Search code examples
androidandroid-activitylifecycle

android how long will our activity be there in the stack


My concern is, how long will our activity be there in the stack?

What I mean is, when the home button is pressed from my app and then my app is launched again by clicking its icon, it will regain the correct place from where I pressed the home button without writing any special code for this.
I don't know whether I'm right, I think that my app is pushed to a stack, and when I launched it, it's pulled from the server.
I want to know how long will be in that stack or any other place where it is stored? Will it be replaced by some other app after pressing the home button and using many other apps?


Solution

  • Your activity will remain loaded until Android decides it needs the resources back. There are methods you can override in your activity to deal with this. Read more here.

    Edit: See comment below for newer link.