Actiivity 生命周期,如下图所示: onCreate  onStart (onRestarted)  onResume  onPaused(to onResume(User navigates to the activity))  onStop  onDestroy

onCreate 方法: 一定要实现OnCreate方法,初始化 组件和布局。

onPause 方法:用户离开activity是的第一个被触发的方法。

onDestroy 方法: 系统也许直接kill了process,这个方法未必会被调用。

An activity can exist in essentially three states:

Resumed
The activity is in the foreground of the screen and has user focus. (This state is also sometimes referred to as "running".)
Paused
Another activity is in the foreground and has focus, but this one is still visible. That is, another activity is visible on top of this one and that activity is partially transparent or doesn't cover the entire screen. A paused activity is completely alive (the Activity object is retained in memory, it maintains all state and member information, and remains attached to the window manager), but can be killed by the system in extremely low memory situations.
Stopped
The activity is completely obscured by another activity (the activity is now in the "background"). A stopped activity is also still alive (the Activity object is retained in memory, it maintains all state and member information, but is not attached to the window manager). However, it is no longer visible to the user and it can be killed by the system when memory is needed elsewhere.

两个Activity跳转时的生命周期方法调用顺序, 例如 Activity A 跳转到 Activity B:

  1. Activity A's onPause() method executes.     //先执行A的onPause方法
  2. Activity B's onCreate()onStart(), and onResume() methods execute in sequence. (Activity B now has user focus.)  //Activity B's onCreate、onStart、onResume方法
  3. Then, if Activity A is no longer visible on screen, its onStop() method executes. // 执行A的onStop方法

综上,如果有数据交换、交互,请在A的onPause里面执行,否则B启动了也找不到新数据。

最新文章

  1. 阿里巴巴B2B搜索学习
  2. IIS下图片防盗连设置详解
  3. JSON.toJSONString的jar包问题
  4. NSPredicate 查询/搜索
  5. 第十章:Python の 网络编程基础(二)
  6. sass基本用法
  7. Djangon
  8. HTTP协议08-请求首部字段
  9. 小程序 showModal content换行
  10. linux 执行远程linux上的shell脚本或者命令以及scp 上传文件到ftp--免密码登陆
  11. openwrt中在软件包中定义PKG_INSTALL将会发生什么?
  12. php file_get_contents fopen 连接远程文件
  13. C#设计模式--设配器模式
  14. [学习]仿照cnblog 搭建 Oracle RAC 双节点 困.. 后续做不下去了..
  15. 独特的deadlock(仅update语句也能造成死锁)
  16. storm配置:如何解决worker进程内存过小的问题
  17. Mvc4 Layout布局与页面SEO信息title,keyword,description
  18. .net core系列之《新一代的配置系统Configuration在支持多数据源,热更新,层级化方面代码快速实践》
  19. 在SharePoint解决方案中使用JavaScript (1) – 引用.js文件
  20. python的第一个程序“Hello,World”,传闻要想学好新语言....

热门文章

  1. .clone事件当你克隆的时候,DOM节点是克隆出来了,但是克隆出来的节点不能运行时事件 ...
  2. How good are detection proposals, really?
  3. SpringBoot学习11:springboot异常处理方式1(自定义异常页面)
  4. 简单webservice实现(xFire1.2)
  5. vue学习之路 - 0.背景
  6. Oracle中文乱码解决
  7. 深入理解java虚拟机学习笔记(一)JVM内存模型
  8. 精读《12 个评估 JS 库你需要关心的事》
  9. tcl之控制流-foreach
  10. tcl之控制流-while