管理Activity的生命周期

As a user navigates through, out of, and back to your app, the Activity instances in your app transition between different states in their life cycle.前端

做为一个用户经过导航进出和回到你的应用程序的这个过程当中,你应用程序的Activity实例在它的生命周期的不一样状态之间转换。网络

For instance, when your activity starts for the first time, it comes to the foreground of the system and receives user focus.app

例如:当你的Activity第一次启动时,它会出如今系统的最前端并接受用户的焦点。ide

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.ui

在这个过程当中,Android系统调用了Activity一系列的生命周期方法,在这些方法中你能够设置用户界面和其余组件。this

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).翻译

若是用户执行一个动做去启动其余的Activity或者切换到另外一个应用程序,随着当前Activity移动进后台,系统会调用另外一组生命周期方法。(这里的Activity再也不是可见的,可是它的实例和它的状态依然保持不变)component

Within the lifecycle callback methods, you can declare how your activity behaves when the user leaves and re-enters the activity.orm

在生命周期的回调方法中,你能够声明Activity在用户离开以及从新进入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.

这一课阐述了生命周期回调方法的重要性。(好吧接下来不会翻译了。)

相关文章
相关标签/搜索