android:activity生命周期及几个主要函数应当做的事情

本文系作者原创,转载请附原文地址,谢谢。

原文地址:http://write.blog.csdn.net/postedit/47342183


前言:

android的activity生命周期问题是个老生常谈的问题了,各大社区都有很多帖子说这个问题。
如果我说,这篇文章是我百分百原创的,那我自己都要打自己的脸,因为API中已经说了很多内容了,但是API是绝对不会将“个人理解”性的东西放进去的。这篇文章是在谈我看了API,以及同行的文章后自己的理解,并试图让这种理解更有利于程序的规范性。
正如上文所言,是谈理解的,所以不去做翻译工作。
许多前辈在以前对这生命周期问题的正确理解应当得到肯定和尊重。但这里无法像论文中那样。

正文:



Android生命周期图

本来还想语言描述一下,但是发现任何语言在这个经典的图面前都是没有必要的。

首先先看一下API文档说了些什么,(我在word中做了一些缩进效果,到这里反而变乱码)

 

 

Method

Description

Killable?

Next

l  onCreate()

Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously frozen state, if there was one.

Always followed by onStart().

No

onStart()

n  onRestart()

Called after your activity has been stopped, prior to it being started again.

Always followed by onStart()

No

onStart()

n  onStart()

Called when the activity is becoming visible to the user.

Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.

No

onResume() or

onStop()

u  onResume()

Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it.

Always followed by onPause().

No

onPause()

u  onPause()

Called when the system is abo

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值