阅读143 返回首页    go 阿里云 go 技术社区[云栖]


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.



最后更新:2017-04-02 15:28:26

  上一篇:go iPhone5过时,谁做过?
  下一篇:go 东方程序员怎么看西方程序员3