android 我们的 Activity 会在堆栈中存在多长时间
我关心的是,我们的 Activity 会在堆栈中存在多长时间?
我的意思是,当从我的应用程序按下主页按钮,然后通过单击其图标再次启动我的应用程序时,它将重新获得我按下主页按钮的正确位置,而无需为此编写任何特殊代码。
我不知道我是否正确,我认为我的应用程序被推送到堆栈中,当我启动它时,它是从服务器中拉出的。
我想知道该堆栈或存储它的任何其他位置会保存多长时间?按主页按钮并使用许多其他应用程序后,它会被其他应用程序取代吗?
My concern is, how long will our activity be there in the stack?
What I mean is, when the home button is pressed from my app and then my app is launched again by clicking its icon, it will regain the correct place from where I pressed the home button without writing any special code for this.
I don't know whether I'm right, I think that my app is pushed to a stack, and when I launched it, it's pulled from the server.
I want to know how long will be in that stack or any other place where it is stored? Will it be replaced by some other app after pressing the home button and using many other apps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 Activity 将保持加载状态,直到 Android 决定需要取回资源。您可以在活动中重写一些方法来处理此问题。请在此处了解更多信息。
编辑:请参阅下面的评论以获取更新的链接。
Your activity will remain loaded until Android decides it needs the resources back. There are methods you can override in your activity to deal with this. Read more here.
Edit: See comment below for newer link.
您还应该查看有关 Android 活动生命周期的文档:
http://developer.android.com/reference/android/app/Activity .html#ActivityLifecycle
和进程生命周期:
http://developer.android.com/reference/android/app/Activity .html#ProcessLifecycle
http://www.edu4java.com/android_course/processes-and-threads .html#Lifecycle
当 Android 需要回收资源时,存在一个层次结构,其中的 Activity 将首先被终止:
启动的服务startService()
)You should also see the documentation on the Android Activity Lifecycle:
http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
and Process Lifecycle:
http://developer.android.com/reference/android/app/Activity.html#ProcessLifecycle
http://www.edu4java.com/android_course/processes-and-threads.html#Lifecycle
There is a hierarchy of which activities will be killed first when Android needs to reclaim resources:
startService()
)