I am trying to bullet proof my application so that if it's memory has been reclaimed by the Android OS because of low memory or non-usage when it is pulled to foreground again I can ensure it does not crash.
I have handled the problem of the application being killed and restarted with persisting the data, but I want to be able to recover from the background if the memory has be reclaimed and the app is still running, starting in the Activity it was last running in.
To do this I want to be able to force this situation on the device (and with the app still running). I have seen the SO items for emulating [How do you simulate low memory in the Android emulator?, by killing every Activity https://stackoverflow.com/a/10799988/4107331[1] but I want to have the real deal on the device.
So basically I would like to shove my app to the background, force its memory to be reclaimed, pull it to the Foreground so I can verify that it recovers correctly - all on the device. Simple, right?