活动生命周期的Andr​​oid [英] activity life cycle Android

查看:108
本文介绍了活动生命周期的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读这里和其他地方对生命周期的几个职位,但我仍然感到困惑。做什么我们存储在的onPause,我们如何保存它,你怎么记得它在onresume方法。任何更多的信息,如果可能的一个具体的例子是大大AP preciated。

I have read several posts on here and elsewhere about the life cycle but I'm still confused. What do we store in the onpause, how do we store it and how do you recall it in the onresume Method. Any more info and if possible a detailed example would be greatly appreciated.

推荐答案

这是什么意思

有关进一步的解释

  • 的onCreate(捆绑)是初始化你的活动。最重要的是,在这里你会通常所说的setContentView(INT)与布局资源定义你的用户界面,并使用findViewById(int)以获取你需要用编程方式进行交互在UI中的小部件。
  • 的onPause()是对付离开活动的用户。最重要的是,由用户作出的任何变更应在此时(通常到ContentProvider的保持中的数据)提交。
  • onResume() onRestoreInstanceState(包)后调用,onRestart(),或在onPause(),为您的活动启动与用户交互。这是一个好地方,开始动画,开放异接入设备(如摄像机)等。
  • 的onDestroy()之前的活动被销毁执行任何最后的清理。发生这种情况可能是因为该活动结束(有人称为完成()就可以了,或因为系统暂时销毁活动的这种情况下,以节省空间,你可以用isFinishing()方法,这两种方案之间的区别。
  • onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically.
  • onPause() is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data).
  • onResume() Called after onRestoreInstanceState(Bundle), onRestart(), or onPause(), for your activity to start interacting with the user. This is a good place to begin animations, open exclusive-access devices (such as the camera), etc.
  • onDestroy() Perform any final cleanup before an activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.

您可以在这里看到这一切。希望它能帮助。

You can see it all here . Hope it helps.

这篇关于活动生命周期的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆