当前位置:网站首页>Activity启动模式和生命周期实测结果
Activity启动模式和生命周期实测结果
2022-06-23 04:14:00 【木子102】
面试的时候经常被面试官官问到activity的生命周期问题,而我们平常又是只简单了解那几种常见的,而面试官一边都是问比较奇葩的情况的生命周期,故自己写了个demo,认真检测一下真实的情况结果(最尴尬的就是面试官说,回去试一试)

Activity启动模式
standard:怎么样都要创建(默认启动模式)
singleTop:顶上不是target Activity,new一个
singleTask:顶上不是target Activity,移除target之上的,把自己变成top。
singleInstance:开辟私有的task,完全独立于程序的其他activity的task。
standard模式
一、 正常情况下启动一个activity,其生命周期:(Activity_A做测试)
1、启动->back键返回的情况:
onCreat()->onStart()->onResume()->onPause()->onStop()->onDestroy()
2、启动->home桌面->再打开app(没被杀死的情况下):
onCreat()->onStart()->onResume()->onPause()->onStop()->onRestart()->onStart()->onResume()
singleTop模式
一、 正常情况下启动一个activity,其生命周期:(Activity_B做测试)
1、启动->back键返回的情况:结果同standard模式
2、启动->home桌面->再打开app(没被杀死的情况下):结果同standard模式
3、顶部已经有,再次启动自己的情况:
onCreat()->onStart()->onResume()->onPause()->onNewIntent()->onResume()->onPause()->onStop()->onDestroy()
4.栈中已经有,但是不是在顶部的情况:
singleTask模式
一、 正常情况下启动一个activity,其生命周期:(Activity_B做测试)
1、启动->back键返回的情况:结果同standard模式
2、启动->home桌面->再打开app(没被杀死的情况下):结果同standard模式
3、顶部已经有,再次启动自己的情况:结果同singleTop模式
4.栈中已经有,但是不是在顶部的情况:
singleInstance模式
一、 正常情况下启动一个activity,其生命周期:(Activity_B做测试)
1、启动->back键返回的情况:结果同standard模式
2、启动->home桌面->再打开app(没被杀死的情况下):结果同standard模式
3、顶部已经有,再次启动自己的情况:结果同singleTop模式4.栈中已经有,但是不是在顶部的情况:结果同singleTask模式
Activity A启动B 然后返回A A和B的生命周期变化情况(顺序)

边栏推荐
- Redis cache penetration solution - bloom filter
- 啊哈C语言 第7章 有了它你能做更多的事(第27-28讲)
- Shifu, the open source development platform of the Internet of things, is open for internal testing! Release of the first version of technical documents
- C primer plus學習筆記 —— 2、常量與格式化IO(輸入/輸出)
- visdom的使用
- 常用的无线充发射IC芯片
- The author believes that the so-called industrial Internet is a process of deep integration of industry and the Internet
- Yingjixin ip5566 with type-C port 3A charging and discharging fast charging mobile power supply 5W wireless charging in one SOC
- 制造业数字化转型存在问题及原因分析
- Ansible 使用普通用户管理被控端
猜你喜欢

英文字母pc是什么意思,互联网的pc指的是什么

FS2119A同步升压IC输出3.3V和FS2119B同步升压IC输出5V

阿里云对象存储oss+picgo+typora实现构建图床

What does the English letter PC mean? What does the Internet PC mean

Win11如何开启移动热点?Win11开启移动热点的方法

June 22, 2022: golang multiple choice question, what does the following golang code output? A:3; B:1; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai

Jvm: when a method is overloaded, the specific method to call is determined by the static type of the incoming parameter rather than the actual type of the parameter

How much disk IO will actually occur for a byte of the read file?

What benefits have digital collections enabled the real industry to release?

How to move the software downloaded from win11 app store to the desktop
随机推荐
Opencv display image
Use of visdom
技能自检 | 想当测试Leader,这6项技能你会吗?
A bit of knowledge - folding forging and Damascus steel
低成本5W无线充电器方案FS68001B简便充电芯片
Oracle异常
Software design and Development Notes 2: serial port debugging tool based on QT design
Wechat applet: an artifact for calculating the full amount of orders
PAT 乙等 1023 组个最小数
Win11如何开启移动热点?Win11开启移动热点的方法
jvm: 方法重载时,具体调用哪个方法,是由传入参数的静态类型来决定的,而不是由参数的实际类型来决定
AHA C language Chapter 8 game time is up (lesson 29)
Wechat applet: a new interesting test
visdom画多条动态损失曲线
数字藏品如何赋能经济实体?
Yingjixin ip5566 with type-C port 3A charging and discharging fast charging mobile power supply 5W wireless charging in one SOC
Low cost 5W wireless charger scheme fs68001b simple charging chip
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-7 personal solutions
Redis cache penetration solution - bloom filter
STC 32-bit 8051 MCU development example tutorial I development environment construction




