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
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.
You can usually trigger this by throwing your app into the background, and then launching 10-20 apps (depending on the device). This will eventually cause your process to be terminated, which I would assume would be preceded by the onTrimMemory()
callback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With