Search code examples
androidandroid-activityandroid-lifecycle

How an Activity is killed by Android?


As we know Android would kill a paused Activity in some conditions. And there is a FIFO back stack of Activities.

My questions are as follows:

  1. How Android kills an Activity without pulling it from the back stack (it might affect the top active Activity)

  2. After killing it, what things are released from this Activity? And can I still get this Activity's instance?


Solution

  • Android does not kill Activities "separately", it kills the whole app process with all Activities.

    The only way to get an Activity killed by the system is to set Don't keep Activities flag in device's Developer Options. However this option is just for development, not for applications in release.