This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about lifietime of activities

 
Peter Sorotokin
Ranch Hand
Posts: 36
1
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In the book that I am reading there is a phrase :

"Even if an application has only one activity and the activity is killed, the
application will still be running in memory"

In this phrase , the underlined word killed , does mean onDestroy() ???
If yes , In several book , I read that when onDestroy() is called by Android , the resourses
that were ocuupied by application will be free ???
I am confuses . Which one is correct ??? The phrase that I mentioned or the things that I read in
several books ???
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you check the javadocs of the Activity class you'll see that onDestroy will be called before the Activity is terminated.

But an application will normally consist of more than just a single Activity - there could be other activities still running, or services, or broadcast receivers, or providers. Each has their own associated set of resources. Only if none of those components run any more will all of the application resources be disposed of (like an android.app.Application if there is one).
 
Irina Goble
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter, in what context did you find that sentence? The key word here is activity. As Ulf said there are other app components. Plus, if an activity is killed because of low memory it still can have its state saved so it can be recreated when the app comes in the foreground. The best place to learn about this is the Activity page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic