ActivityLifecycle.zip
As a user navigates through, out of, and back to your app, theActivity
instances
in your app transition between different states in their lifecycle. For instance, when your activity starts for the first time, it comes to the foreground of the system and receives user focus. During this process, the Android system calls a series of lifecycle
methods on the activity in which you set up the user interface and other components. If the user performs an action that starts another activity or switches to another app, the system calls another set of lifecycle methods on your activity as it moves into
the background (where the activity is no longer visible, but the instance and its state remains intact).
Within the lifecycle callback methods, you can declare how your activity behaves when the user leaves and re-enters the activity. For example, if you‘re building a streaming video player, you might pause the video and terminate the network connection when the user switches to another app. When the user returns, you can reconnect to the network and allow the user to resume the video from the same spot.
This class explains important lifecycle callback methods that each Activity
instance
receives and how you can use them so your activity does what the user expects and does not consume system resources when your activity doesn‘t need them.
用户通过导航,走出,回到你的应用, Activity
实例应用程序生命周期的不同状态之间的过渡。例如,当你的活动第一次开始,它转到系统的前面并接收用户的焦点。在这个过程中,Android系统调用一系列设置用户界面和其他组件的活动的生命周期方法。如果用户执行一个动作,开始另一个活动或切换到另一个应用程序,系统在你的活动中调用另一组生命周期方法,因为它进入后台(活动不再是可见的,但实例及其状态保持不变)。
在生命周期回调方法中,当用户离开和重新进入活动时您可以声明你的活动如何进行。例如,如果您正在构建一个流媒体视频播放器,当用户切换到另一个应用程序时,你可能会暂停视频、终止网络连接。当用户返回时,你可以重新连接到网络,允许用户从同一地点恢复视频。
这个类解释了每个重要的生命周期回调方法 ,Activity
实例接收和如何使用它们,这样你的活动可以满足用户所期望,当你的活动不需要他们时也不消耗系统资源。
原文:http://blog.csdn.net/huayi211113006/article/details/27480183