码迷,mamicode.com
首页 > 其他好文 > 详细

Managing the Activity Lifecycle 管理活动的生命周期

时间:2014-06-05 06:25:32      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:des   android   c   style   class   code   

Managing the Activity Lifecycle

管理活动的生命周期

Previous         Next         Get started
      

Dependencies and prerequisites

依赖和先决条件

如何创建一个Android项目(参见创建一个Android项目)

You should also read

你也应该阅读

Try it out

试一试

ActivityLifecycle.zip

As a user navigates through, out of, and back to your app, the Activity 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).

用户通过导航,跳出,返回到您的应用程序,是您应用程序中Activity实例的生命周期在不同状态之间的过渡。举个例子来说,当您的activity首次开始,它达到系统的前台和接受用户的聚焦。在这个过程之中,Android系统调用一系列的生命周期方法来设置用户界面和其他组件。如果用户开启一个行为动作,开启另一个活动或者切换到另一个界面,系统则会在您的活动中调用另一组生命周期的方法,因为它进入了后台(活动不再是可见的了,但是实例和它的状态依然保持不变)。

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实例接收和如何使用它们,这样达到您的活动用户的期望,以及当您的活动不需要他们不消耗系统资源。

 

Lessons


Starting an Activity
开启一个活动
Learn the basics about the activity lifecycle, how the user can launch your app, and how to perform basic activity creation.
基本了解活动的生命周期,用户怎样可以启动应用程序,以及如何执行基本的创造活动。
Pausing and Resuming an Activity
暂停和恢复一个活动
Learn what happens when your activity is paused (partially obscured) and resumed and what you should do during these state changes.
了解当你的活动暂停(部分被遮挡)和恢复发生了什么,以及在这些状态改变时您应该做些什么。
Stopping and Restarting an Activity
停止和重新启动一个活动
Learn what happens when the user completely leaves your activity and returns to it.
了解当用户完全离开你的活动以及返回到它时发生了些什么。
Recreating an Activity
重新创建一个活动
Learn what happens when your activity is destroyed and how you can rebuild the activity state when necessary.
了解你的活动被销毁以及你在必要时重新创建这个活动时发生了什么。
 

Managing the Activity Lifecycle 管理活动的生命周期,布布扣,bubuko.com

Managing the Activity Lifecycle 管理活动的生命周期

标签:des   android   c   style   class   code   

原文地址:http://blog.csdn.net/xia09222826/article/details/27309859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!