当前位置:网站首页>Activity的四种启动模式
Activity的四种启动模式
2022-08-11 06:44:00 【是小A】
一.standard:
系统默认的启动模式,栈结构,先进后出,打开一个activity入栈,再打开下个activity,接着入栈,我们平时直接创建的Activity都是这种模式的Activity
这种模式的Activity的特点是:只要你创建了Activity实例,一旦激活该Activity,则会向任务栈中加入新创建的实例,退出Activity则会在任务栈中销毁该实例。
二.singleTop:
如果某个Activity自己激活自己,即任务栈栈顶就是该Activity,则不需要创建,其余情况都要创建Activity实例;
三.singleTask:
如果要激活的那个Activity在任务栈中存在该实例,则不需要创建,只需要把此Activity放入栈顶,并把该Activity以上的Activity实例都pop;
四.singleInstance:
如果我们将某个activity设置成这个singleStance启动模式,则当激活这个activity之后单独放到一个栈,下次再使用的时候,直接使用这个栈,比如打电话应用就是一个singleStance模式启动的activity
代码实现有两种方式
第一种在AndroidMainfest中配置 想要的 启动模式
<activity android:name=".SecondActivity" android:launchMode="singleInstance"/>
第二种在Java代码中配置
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//在这里进行逻辑处理
startActivity(intent);
边栏推荐
- linux 安装mysql服务报错
- 一种用于EEG超扫描研究的分析流程
- 进制转换间的那点事
- Find the shops that have sold more than 1,000 yuan per day for more than 30 consecutive days in the past six months
- 2022-08-09 第四小组 修身课 学习笔记(every day)
- SQL sliding window
- 每日sql -查询至少有5名下属的经理和选举
- concept noun
- buu—Re(5)
- unable to extend table xxx by 1024 in tablespace xxxx
猜你喜欢
下一代 无线局域网--强健性
Get Pinduoduo product information operation details
Daily sql--statistics the total salary of employees in the past three months (excluding the latest month)
已解决EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
Discourse's Close Topic and Reopen Topic
Discourse 的关闭主题(Close Topic )和重新开放主题
unable to extend table xxx by 1024 in tablespace xxxx
ROS 话题通信理论模型
Taobao product details API interface
一张图了解JVM八大原子操作
随机推荐
Taobao product details API interface
Discourse's Close Topic and Reopen Topic
求过去半年内连续30天以上每天都有1000元以上成交的商铺
What are the things that should be planned from the beginning when developing a project with Unity?How to avoid a huge pit in the later stage?
How do you optimize the performance of your Unity project?
docker安装mysql5.7(仅供测试使用)
Unity3D learning route?
Redis + lua implements distributed interface current limiting implementation scheme
Find the shops that have sold more than 1,000 yuan per day for more than 30 consecutive days in the past six months
公牛10-11德里克·罗斯最强赛季记录
How Unity programmers can improve their abilities
梅科尔工作室——BP神经网络
微信小程序功能上新(2022.06.01~2022.08.04)
sql--7天内(含当天)购买次数超过3次(含),且近7天的购买金额超过1000的用户
基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现
每日sql-统计各个专业人数(包括专业人数为0的)
Taobao sku API interface (PHP example)
Pinduoduo api interface application example
语音信号处理:预处理【预加重、分帧、加窗】
jar服务导致cpu飙升问题-带解决方法