How to emulate unloading of a background application by Android OS?
<p>For testing purposes I need to easily reproduce a situation when Android system decides to save a state of and kill a background application, in the same manner as it normally does for memory optimization purposes. In fact, I need also to test the restoration process of such a removed process when a user switches back to it.</p>

<p>The straighforward approach would be to open the application and then open more other tasks trying to allocate as much resources as possible. That's too complicated and unreliable. </p>

<p>I've found <a href="http://stackoverflow.com/questions/5075773/how-to-emulate-the-process-of-a-background-activity-is-killed-by-the-system-beca">this question on SO</a>, but the answer implies simply killing the process, which seems not an equivalent, because there seems no means for further automatic restoring of the killed process with a saved state, when a user decides to switch back to the application. If I understand correctly, after such explicit killing the application, if started, will run from very beginning, not from a saved state. Please, correct me, if I'm wrong.</p>

<p>According to Android documentation, what I need is performed by <code>ActivityManager.killBackgroundProcesses(packageName)</code>, but this is the programmatic way of doing the thing. Is there an utility which already provides the same option from UI?</p>
