问题描述
试图找到关于Android应用生命周期的一些信息。所以,想象一下这种情况:我打开的应用程序,比锁屏,并在几个小时的电话杀了我的应用程序的过程。会发生的时候我会解锁界面是什么?我会在屏幕上看到了什么? Android主屏幕?或者应用程序会自动RESTAR给我吗?可以叠加的活动将恢复吗?我会很高兴的任何帮助。谢谢...
Trying to found some information about Android app life cycle. So imagine the situation: I open app and than lock screen, and in a few hours phone kill my app process. What will happen when I will unlock screen ? What I will see at the screen ? Android home screen ? or App will restar automatically for me ? Will stack of activities will restore too ? I'll be glad for any help. Thanks...
推荐答案
活动周期是你的寻找。
有没有这样的东西作为应用程序生命周期或lifecircle。每一件事情都有它自己的生命周期。如果系统需要更多的内存会被杀死如果的onPause()
或的onStop()
状态。如果所有的活动被杀害,该应用程序将不再可见。如果你想要的数据持久化,你必须重写的onPause()
和 onResume()
和保存/恢复你的数据有
There is no such thing as Application lifecycle or lifecircle. Every Activity has it's own lifecycle. If the system needs more ram it will be killed if in onPause()
or onStop()
state. If all your Activities are killed, the app is no longer visible. If you want data to persist you have to Override onPause()
and onResume()
and save/restore your data there.
您的应用程序将不会恢复它自己,如果有遇难的活动。你必须手动跟踪你的活动,如果你想你的活动杀后恢复。
Your Application will never restore on its own, if there is an activity killed. You have to keep track of your activities manually if you want to "resume" after kill of your activities.
要使其更加precise:一个活动可以被杀死,其余可以保持暂停状态。如果然后返回到您的应用程序,你得到这是不杀了你的活动栈中的最后一项活动。
To make it even more precise: One Activity can be killed and the others can remain paused. If you then return to your app you get the last activity in your activity stack which wasn't killed.
这篇关于安卓应用程序生命周期和活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!