问题
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]
回答1:
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.
来源:https://stackoverflow.com/questions/23801934/android-inconsistency-in-documentation-when-may-an-app-be-killed