0

It's seems to me that these articles 1 and 2 are not consistent. Article [1] says that the app is only killable in certain parts of its life cycle. Article [2] says that it is.

Which is right?

[1] Look for the table and the word "killable". [2] Look for "They are killed only as a last resort" in the section on foreground processes.

[Edit 1 start]

Changed the way I did links. Thanks to the guy/girl who made me aware of this by editing my post.

[Edit 2 end]

jgreen81
  • 705
  • 1
  • 6
  • 14
  • I don't get where they contradict. The first article says that they are NOT killable in certain parts of the lifecycle. These parts should be very short (in terms of time spent inside the method). An activity spends most time **between** the listed methods, where it is killable anytime as described in second article. – Chrisport May 22 '14 at 08:59
  • An app should never be "killed" you may finish/destroy the activities or services. The system should be the one deciding when "killing" the app – An-droid May 22 '14 at 09:34

1 Answers1

0

Article ** says that the app is only killable in certain parts of its life cycle.

Apps don't have a lifecycle. The table in question is about the activity lifecycle. Processes also have a "lifecycle" -- covered in your second link -- though personally I would not have chosen that noun.

Which is right?

In general, both, though I think that the second link is slightly out of date. There are more process importance states, and I do not think that "foreground" services are treated the same as "foreground" UI anymore. AFAIK, a "foreground" service moves the process to IMPORTANCE_PERCEPTIBLE, which is lower priority than IMPORTANCE_FOREGROUND. And, as a result (and AFAIK), a process that has a "foreground" service but does not have an activity in the foreground is more likely to be terminated due to low memory conditions than is a process that has an activity in the foreground.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • If a process is killed (and as I understand, this may happen at any point, though rarely when in foreground) then I guess my activites are also killed, no matter what part of the their life cycle they are in. This article says how processes are killed "brutally": "Once Android determines that it needs to remove a process, it does this brutally, simply force-killing it.", http://android-developers.blogspot.dk/2010/04/multitasking-android-way.html – jgreen81 May 22 '14 at 11:37
  • @eversceptic: "If a process is killed (and as I understand, this may happen at any point, though rarely when in foreground) then I guess my activites are also killed, no matter what part of the their life cycle they are in" -- yes, bearing in mind that some parts of their lifecycle only occur while they are in the foreground. Hence, the "killable" column in your first link. – CommonsWare May 22 '14 at 11:59
  • Do I get you right? Are you saying, "Since Activity is only Killable in states where it is not in foreground, a process is implicitely also only killable while no activities are in foreground"? You might be right, but what about services then? AsyncTask etc. might be running? – jgreen81 May 27 '14 at 19:25
  • @eversceptic: "what about services then?" -- they also affect the process importance states that I linked to in my answer. – CommonsWare May 27 '14 at 19:27
  • Yes, they affect priority/importance, but I believe that Android might kill all processes at any time (rarely, I know, but there are no guarantee). I realize that my question has been answered because it really is about the difference in "app"/"process"/"activity". If you want to help me further, I think we should continue as part of my other question which is more relavant now [link](http://stackoverflow.com/questions/23610517/android-state-of-force-killed-applications). PS: Can't get this @-stuff to work. – jgreen81 May 27 '14 at 19:32