O
O
orbit0702019-07-04 16:22:11
Android
orbit070, 2019-07-04 16:22:11

Is this behavior normal?

Hello.
There is an activity and its ViewModel.
By clicking on the button, the text (in LiveData) "Output hello world" is stored in the ViewModel.
As soon as the data is saved, a callback is fired in the activity, which displays "Hello World".
Everything works great, but: when I close the application by pressing the hardware "Back" button, I see in the logs that onDestroy is called on the Activity, onCleared is called on the ViewModel, that is, everything happens as it should, but when I restart the application even after hour, then I immediately display the inscription "Hello World", which should be displayed only if the LiveData in the ViewModel has the inscription "Display hello world".
It turns out that when I close the application, it does not close in fact and nothing is deleted? Or what am I doing wrong?
By the way, if I close the application, and then I clear the list of running applications, then when I restart the application, the inscription is not displayed. But if I close it by simply pressing the "Back" button, even taking into account the fact that onDestroy and onCleared worked, the application still seems to just go into the background, since the data is all in place.
I hope someone will clarify the situation. Of course, I know that Android does not instantly kill activities and everything else, but not for so long. Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question