`
xuanzhui
  • 浏览: 196976 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Activity和Fragment生命周期

阅读更多

搬运自Android Developer

 

Activity

 

Managing the Activity Lifecycle

 

As you'll learn in the following lessons, there are several situations in which an activity transitions between different states that are illustrated in figure 1. However, only three of these states can be static. That is, the activity can exist in one of only three states for an extended 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—the other activity that's in the foreground is semi-transparent or doesn't cover the entire screen. The paused 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 is considered to be in the background. While stopped, the activity instance and all its state information 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 to the next state by calling the next lifecycle callback method. That is, after the system calls onCreate(), it quickly calls onStart(), which is quickly followed by onResume().

That's it for the basic activity lifecycle. 

 

 

 

 

Activities

 

 

关于onStop和onPause导致状态的区别

Difference between onPause and onStop

简单的说,activity被pause后,可能只是一部分被挡住,还有别的地方是可见,或者上面的activity是透明的,但是不能和用户交互;但是stop后是完全不可见的。

 

 

Fragment

 

Building a Dynamic UI with Fragments

 

Fragments



 

 

 

 

  • 大小: 67.7 KB
  • 大小: 80.7 KB
  • 大小: 74 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics