With ICS upwards this may be possible.
This is taken from the android site:
To be notified when the user exits your UI, implement the
onTrimMemory() callback in your Activity classes. You should use
this method to listen for the TRIM_MEMORY_UI_HIDDEN level, which
indicates your UI is now hidden from view and you should free
resources that only your UI uses.
Notice that your app receives the onTrimMemory() callback with
TRIM_MEMORY_UI_HIDDEN only when all the UI components of your app
process become hidden from the user.
See this page for full details http://developer.android.com/training/articles/memory.html