美文网首页
Activity生命周期

Activity生命周期

作者: 野望Echo | 来源:发表于2017-10-10 17:14 被阅读0次

Activity有六种生存状态:Created、Started、Resumed、Pasued、Stopped、Destroyed,其中只有Resumed、Pasued和Stopped三种状态为稳定状态。

Resumed(运行状态):Activity处于前台,可以与用户进行直接交互;

Pasued(暂停状态):Activity被半透明状态或未覆盖全屏的Activity遮挡,此时Activity无法接受用户输入,也无法执行任何代码;

Stopped(停止状态):Activity完全被遮挡,用户不可见,处于后台,但Activity实例及其成员变量状态将会保留,无法执行任何代码。

其他状态都是过度状态(暂时状态)。

状态转变:

1、onCreate()——》Created    onStart() ——》Started  onResume()——》Resumed onPause()——》Paused onStop()——》Stopped onDestroyed()——》Destroyed

2、Paused onResume()——》Resumed

3、Stopped onRestart() onStart()——》Started

相关文章

网友评论

      本文标题:Activity生命周期

      本文链接:https://www.haomeiwen.com/subject/auvpyxtx.html