StartActivity always calls onDestroy for the original activity

When calling the startActivity function (intent intent) from my activity, the onDestroy () method is always called on it, so I lose the state of the fragments, etc.

I understand that onStop must be called, and onDestroy may or may not be called. But my experience is that initial activity is always destroyed.

I understand that if I have activity with listView, with an adapter, etc. Android does not expect me to monitor the status of the adapter simply because I click another action on top of it, right?

Am I right? What can cause this behavior?

thanks

+4
source share
1 answer

On some devices (Galaxy S2, etc.), there is a parameter that can lead to the destruction of actions during debugging. You can find it in:

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

Do not keep activities

Uncheck this box to stop actions that are always destroyed when you leave them.

+13
source

Source: https://habr.com/ru/post/1491528/


All Articles