Android Liftcycle
As you'll learn in the following lessons, there are several situtations in which an activitytransitions between different states that are illustrated in figure 1. However, only three ofthese states can be static. That is, the activity can exist in one of only three states for anextended period of time:
- Resumed
- In this state, the activity is in the foreground and the user can interact with it.(Also sometimes referred to as the "running" state.)
- Paused
- In this state, the activity is partially obscured by another activity—theother activity that's in the foreground is semi-transparent or doesn't cover the entire screen. Thepaused activity does not receive user input and cannot execute any code.
- Stopped
- In this state, the activity is completely hidden and not visible to the user; it isconsidered to be in the background. While stopped, the activity instance and all its stateinformation such as member variables is retained, but it cannot execute any code.
The other states (Created and Started) are transient and the system quickly moves from them tothe next state by calling the next lifecycle callback method. That is, after the system callsonCreate()
, it quickly callsonStart()
, which is quickly followed by onResume()
.
Note: The system calls onDestroy()
after it has already calledonPause()
and onStop()
in all situations except one: when you callfinish()
from within the onCreate()
method. In some cases, such as when your activity operates as a temporary decision maker tolaunch another activity, you might callfinish()
from within onCreate()
to destroy the activity. In this case, the systemimmediately callsonDestroy()
without calling any of the otherlifecycle methods.
更多相关文章
- Android 自定义控件之图片裁剪
- android访问网络图片
- android checkbox 定制(修改checkbox 的图片)
- 【Android】简单图片浏览器
- android图像处理系列之三--图片色调饱和度、色相、亮度处理
- Android使用xml自定义图片
- Android 图片缩放与旋转
- android 获取图片
- android 读取,写入图片到sd卡源码