Srinivasan
Srinivasan

Reputation: 4661

No longer visible App killed by the System in Android Applcation Development

I am fresh to android development.I have created a android application works properly.But my issue is when i click the "home" button it goes to onPause() method and onStop() maintain activity state.Then i used some other application in my device.After 1 hour again i go to "home" click my application icon based on Activity life cycle it should goes to onRestart() method instead my app again go to "onCreate() method.I thought my application is killed by System because it's no longer visible to the user.

So can you all help me to keep the app activity state alive.

Thanks....

Upvotes: 1

Views: 208

Answers (2)

Sudhaker
Sudhaker

Reputation: 785

It depends on lot of factors on why an application is killed when in background for a long time.

  • Memory requirement / consumption being the first in that, if you are launching too many applications after you have sent your application to background then its obvious that your application will be killed by the OS to provide memory for other applications.

  • Second we have lot of apps in the market now a days which will terminate the Apps to increase the battery life, so check if you have any such apps installed in your device because of which your application will require to go through onCreate() again.

Check this to get an idea on when the app will be killed.

You might also be interested in this if you want to know further.

Upvotes: 1

Uriel Frankel
Uriel Frankel

Reputation: 14612

If what you need is to save data and state you can save it in the Shared Preferences. Then on the second time you can check the preferences and restore all of the information from there.

Upvotes: 0

Related Questions