For testing purposes, I need to easily reproduce a situation where the Android system decides to save state and kill the background application in the same way as it is usually done to optimize memory. In fact, I also need to test the recovery process of such a remote process when the user switches to it.
The incoherence based approach is to open the application and then open other tasks, trying to allocate as many resources as possible. It is too complicated and unreliable.
I found this question on SO , but the answer implies simply killing the process, which seems not equivalent, because there is no means for further automatic recovery of the killed process with the saved state when the user decides to return to the application. If I understand correctly, after such an explicit killing of the application, if it is running, it will be launched from the very beginning, and not from the saved state. Please correct me if I am wrong.
According to the Android documentation, I need to execute ActivityManager.killBackgroundProcesses(packageName) , but this is a programmatic way to do this. Is there a utility that already provides the same feature from the user interface?
source share