概述

  The following diagram shows the important state paths of an Activity. The square rectangles represent callback methods you can implement to perform operations when the Activity moves between states. The colored ovals are major states the Activity can be in.

  在官网上,看到这个图,连官网自己都说很重要的图,忍不住就截了个图:

  There are three key loops you may be interested in monitoring within your activity:  

  • The entire lifetime of an activity happens between the first call to onCreate(Bundle) through to a single final call to onDestroy(). An activity will do all setup of "global" state in onCreate(), and release all remaining resources in onDestroy(). For example, if it has a thread running in the background to download data from the network, it may create that thread in onCreate() and then stop the thread in onDestroy().
  • The visible lifetime of an activity happens between a call to onStart() until a corresponding call to onStop(). During this time the user can see the activity on-screen, though it may not be in the foreground and interacting with the user. Between these two methods you can maintain resources that are needed to show the activity to the user. For example, you can register a BroadcastReceiver in onStart() to monitor for changes that impact your UI, and unregister it in onStop() when the user no longer sees what you are displaying. The onStart() and onStop() methods can be called multiple times, as the activity becomes visible and hidden to the user.
  • The foreground lifetime of an activity happens between a call to onResume() until a corresponding call to onPause(). During this time the activity is in front of all other activities and interacting with the user. An activity can frequently go between the resumed and paused states -- for example when the device goes to sleep, when an activity result is delivered, when a new intent is delivered -- so the code in these methods should be fairly lightweight.

The entire lifecycle of an activity is defined by the following Activity methods. All of these are hooks that you can override to do appropriate work when the activity changes state. All activities will implement onCreate(Bundle) to do their initial setup; many will also implement onPause() to commit changes to data and otherwise prepare to stop interacting with the user. You should always call up to your superclass when implementing these methods.

public class Activity extends ApplicationContext {protected void onCreate(Bundle savedInstanceState);protected void onStart();protected void onRestart();protected void onResume();protected void onPause();protected void onStop();protected void onDestroy();}

转载于:https://www.cnblogs.com/listened/p/4140967.html

android-Activity的执行流程相关推荐

  1. Android Activity的启动流程分析:以Launcher启动一个Activity为例,分析应用进程的创建、Activity的启动,以及他们和AMS之间的交互

    文章目录 一. Step1 - Step 11:Launcher通过Binder进程间通信机制通知ActivityManagerService,它要启动一个Activity: Step 1. Laun ...

  2. android按键精灵执行流程,android按键精灵学习_框架搭建

    android按键精灵脚本的思路 1.主线循环 2.支线循环 3.功能模块 4.代码命令 5.固定模块 6.检测状态模块, 通常是启动一个线程,监控多少分钟后状态还没改变,就跳出支线循环并记录时间和结 ...

  3. android activity启动流程_1307页!一线大厂Android面试全套真题解析!

    /   前言   / 金九银十到了,很多读者都反映有面试的需求,所以我特地给大家准备了一点资料! 下面的题目都是大家在面试一线互联网大厂时经常遇到的面试真题和答案解析,如果大家还有其他好的题目或者好的 ...

  4. Android图片加载框架最全解析(二),从源码的角度理解Glide的执行流程

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/53939176 本文同步发表于我的微信公众号,扫一扫文章底部的二维码或在微信搜索 郭 ...

  5. Android 四大组件之——Acitivity(三) 深入了解Activity的启动流程

    上图为整个Activity的启动流程 接下来我们大概分析 在我们的Android系统中,应用程序是由Launcher这个应用启动起来的.当我们安装好应用程序之后,就会在Launcher的界面上生成一个 ...

  6. Android通过WindowManager.LayoutParams修改Activity窗口亮度流程

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_38059988/article/ ...

  7. 【拒绝一问就懵】之Activity的启动流程

    背景介绍 从事开发到了一定阶段,想要提高就必须搞明白系统的一些工作原理.为什么?因为只有明白了这些,你才能针对平台的特性写出优质的代码.当遇到棘手的问题时,你才能更快速的结合系统原理去寻找最优解决方案 ...

  8. Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?

    Android Activity为什么要细化出onCreate.onStart.onResume.onPause.onStop.onDesdroy这么多方法让应用去重载? 原创链接:http://bl ...

  9. android activity详解一:概述

    概述 Activities 是一个程序的组件之一.它的主要功能是提供界面. 一个程序一般由多个Activity组成,各activities之间关系很松散,它们之间没有直接的关联.必须有一个activi ...

  10. Android Q 开机启动流程

    https://www.it610.com/article/1304931662924124160.htm Android Q 开机启动流程 开机启动概述: step 1: 上电开机 长按power键 ...

最新文章

  1. mysql给root开启远程访问权限,修改root密码
  2. python关闭读写的所有的文件-Python文件操作:文件的打开关闭读取写入
  3. hoj 3005 Game Rigging 强联通分量求缩点
  4. codeforce 589B枚举
  5. tomcat启动时窗口中出现中文乱码的解决办法
  6. vue-router和react-router嵌套路由layout配置方案的区别
  7. android面试题精选
  8. ubuntu下针对php的thrift 安装折腾记录
  9. Android程序捕获未处理异常,处理与第三方方法冲突时的异常传递
  10. 20145209 2016-2017-2 《Java程序设计》第4周学习总结
  11. bzoj 3545: [ONTAK2010]Peaks Kruskal重构树
  12. 图像分割算法及与目标检测、目标识别、目标跟踪的关系
  13. c语言约瑟夫环分析报告,约瑟夫环C语言实现验证报告.doc
  14. CAD图纸、影像地形、倾斜摄影、矢量数据统统搬入图新地球,一键浏览分析
  15. 黄永成think php rest,Rest控制器
  16. 深入浅出Yolo系列之Yolov3Yolov4Yolov5Yolox核心基础知识完整讲解
  17. 《Look More Than Once(LOMO):An Accurate Detector for Text of Arbitrary Shapes》论文笔记
  18. 软件配置 | pip下载第三方库文件及配置pip源的不完全总结
  19. 计算机毕设(附源码)JAVA-SSM基于Internet快递柜管理系统
  20. excel VBA快递查询

热门文章

  1. 将数据库的操作代码从servlet中剥离,封装到DAO中
  2. golang中的recover
  3. 某linux主机的/etc/rc.d/rc.inet1文件中有如下语句,请修正错误,并解释其内容。
  4. java:socket通信
  5. oracle:更改序列
  6. I am too vegetable to all kill the 51nod problems on level 2 and 3.
  7. AGG第二十课 agg::ellipse 方法approximation_scale()
  8. OSChina 周一乱弹 ——渴望咪咪还是渴望力量,都能给你
  9. 每周一书《Oracle 12 c PL(SQL)程序设计终极指南》
  10. 去除tableview中每个cell的分段线