问题
Android system may decide to remove an application process when the system is low on memory, so to reclaim resources for more important work ( ie. to start a service belongs to another application ). However, I couldn't be sure if it's possible for the Android system to remove ONLY application task ( back stack ) without touching the corresponding app process?
If this is possible, it's also possible the system destroys the back stack activities by performing a call to each onDestroy() callback. So, how can we catch this task removal just like we catch it in a Service ( through onTaskRemoved )
Thanks
回答1:
When Android wants to reclaim resources (or just because Android likes to tidy up), it will usually just kill off any OS processes that are not hosting foreground activities or foreground services. Android does this by actually killing the OS process, therefore onDestroy()
will NOT be called on any components that are active in those OS processes. You will not be warned about this, so there is no way to "catch" this behaviour.
来源:https://stackoverflow.com/questions/38953868/android-low-memory-killer-application-back-stack