Question: How can I cause a Low Memory Condition on an Android device so that my Activity is destroyed and the associated Application class receives onTrimMemory() while my application is in the background. I am having issues in my app related to recovery from being killed by the Android OS, when in the background, and want to be able to step through the code in the debugger, but I can't regularly generate this condition, particularly when connected to the debugger :)

Thank You,
Gary

Answer: 
Another way to do it:  

 In your device:   

Go to Settings -> Developer options and check "Dont keep activities".   

This will kill your activity as soon it goes in the background.
While your app is on foreground, you can kill cached processes via shell

```
adb shell am kill-all

```

then leave your application (make it go background), soon it will receive a `onTrimMemory()` callback.

This happens because system thinks too many apps are dying and that should be a low memory situation.