startActivity is always calling onDestroy on the original activity

android

Solution

On some devices (Galaxy S2 etc.), there is a setting which can cause activities to be destroyed whilst debugging. You can find this in:

settings > developer options > go down to the bottom under apps section > 

`Do not keep activities`

Uncheck this option, to stop activities always being destroyed when you leave them.

Problem

When calling startActivity(Intent intent) from my activity, onDestroy() method is always being called on it, so I lose my state of fragments, etc... My understanding is that onStop should be called, and onDestroy could or could not be called. But my experience is that the original activity is always being destroyed. I understand that if I have an activity with a listView, with an adapter, etc... Android does not expect me to sve the state of the adapter simply because I push another activity on top of this one, right? Am I correct? What could be triggering this behavior? Thank you

Original source