Android的生命周期活动[复制](Android life cycle activities [

2019-10-17 12:48发布

可能重复:
Android的活动生命周期-什么是所有这些方法呢?

我有一个活动是主叫menuActivity和其他活动,呼吁birthDate

当我运行应用程序的menuActivity成为活动之一,当我点击一个按钮,第二个成为活动其一是birthDate

我的问题是:

当第一个活动变得活跃另一项活动去的背景和主要活动涉及到forground,我有哪些方法来实现? OnResumeOnCreate还是什么?

Answer 1:

的onResume ..检查以下http://developer.android.com/training/basics/activity-lifecycle/index.html



Answer 2:

尝试阅读的Android文件,了解活动的生命周期

http://developer.android.com/training/basics/activity-lifecycle/pausing.html

像从链接下面图像



Answer 3:

它的onResume,你将必须实现。

看看这个Android活动的生命周期



Answer 4:

你应该阅读http://developer.android.com/reference/android/app/Activity.html你正在寻找的方法是的onResume()。



Answer 5:

如果你想要做一些动作时,活动恢复,你必须把里面的代码onResume()因为onResume()是调用的方法,每次你的活动涉及到前台。 onCreate()仅在活动周期调用一次。



Answer 6:

在该系统的活动作为活动堆栈管理。 当一个新的活动启动时,它被放置在堆栈的顶部,并成为运行活动 - 以前的活动始终保持在它下面的堆栈,并且不会再次走到前台,直到新的Activity退出。

活动主要有四种状态:

**If an activity in the foreground of the screen (at the top of the stack), it is active or running.**

**If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.**

**If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.**

**If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state.**

下图显示了一个活动的重要状态的路径。 长方形表示你可以实现当活动状态之间移动来执行操作的回调方法。 彩色的椭圆形是主要国家的活动可以英寸



文章来源: Android life cycle activities [duplicate]