P
P
Pavel Bykov2018-02-19 16:45:54
Android
Pavel Bykov, 2018-02-19 16:45:54

Why is there such a strange sequence of method calls in an Activity?

Hello, I came across such a strange sequence of calls in android, namely:

onCreate -> onStart -> onResume

Then I close the app and the following happens
onPause -> onStop

Then I expand the application and for some reason instead of calling
onRestart -> onStart

it starts the call in the following sequence
onCreate -> onStart -> onResume -> onDestroy

and here the question arises, how to avoid calling onCreate again and why at the very end the onDestroy method is called in the application, but the Activity is not destroyed, but continues to work ...
For good, I would somehow save the objects that remain in the same Activity and prevent re-call onCreate

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Bykov, 2018-02-19
@mafof

I found a solution to this problem, it turns out that the noHistory property in AndroidManifest.xml makes such strange behavior of calling methods ....

A
aol-nnov, 2018-02-19
@aol-nnov

https://developer.android.com/guide/components/act...
If the app in the background has been killed, there's no way you can prevent onCreate from being called

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question