Activity的四种启动模式
来源:互联网 发布:建筑工程造价软件 编辑:程序博客网 时间:2024/06/07 17:16
刚刚重新学了一下activity的四种启动模式,现在做一下小结.
Standard模式
"standard"
(the default mode)
Default. The system creates a new instance of the activity in the task fromwhich it was started and routes the intent to it. The activity can be instantiated multiple times,each instance can belong to different tasks, and one task can have multiple instances.
standard模式是activity的默认启动模式,它可以多次的被实例化,并且每一个实例可以属于不同的任务,一个任务可以实例化多次。什么意思呢,就是说当你通过一个intent去开启一个activity的时候,可以多次的开启这个页面。加入有一个按钮用来开启自身这个activity,那么每按一下这个按钮,就会启动一个activity,就是实例化一次。这些activity会在一个任务栈中进行堆叠排列起来。就像下面这样,当我们点击按钮去开启自身这个activity时,会创建一个实例,并压入栈当中。
SingleTop模式
"singleTop"
- If an instance of the activity already exists at the top of the current task, the systemroutes the intent to that instance through a call to its
onNewIntent()
method, rather than creating a new instance of theactivity. The activity can be instantiated multiple times, each instance canbelong to different tasks, and one task can have multiple instances (but only if theactivity at the top of the back stack isnot an existing instance of the activity).
"singleTask"
- The system creates a new task and instantiates the activity at the root of the new task.However, if an instance of the activity already exists in a separate task, the system routes theintent to the existing instance through a call to its
onNewIntent()
method, rather than creating a new instance. Onlyone instance of the activity can exist at a time.Note: Although the activity starts in a new task, theBack button still returns the user to the previous activity.
"singleInstance"
Same as"singleTask"
, except that the system doesn't launch any other activities intothe task holding the instance. The activity is always the single and only member of its task;any activities started by this one open in a separate task.
采用singleInstance模式启动一个activity时,这个activity将会单独在一个任务栈中,并且只有一个实例,整个操作系统中也只有这么一个实例的activity存在于属于它自己的任务栈中。什么意思呢,就是说当我去开启这种模式的activity时,将会在一个单独的任务栈中去实例化它,并且只能实例化一次。比如呼叫来电界面,它只能实例化一次,如果可以实例化多次,当有另一个电话打进来时就会又开启一个呼叫来电界面。
- Activity的四种启动模式
- Activity的四种启动模式
- Activity的四种启动模式2
- Activity的四种启动模式
- activity的四种启动模式
- Activity启动的四种模式
- Activity的四种启动模式
- activity 的四种启动模式
- activity 的四种启动模式
- 分析Activity的四种启动模式
- Activity的四种启动模式
- Activity的四种启动模式
- Activity的四种启动模式
- Activity 四种启动模式的区别
- Activity的四种启动模式
- activity 的四种启动模式
- Activity的四种启动模式
- Activity的四种启动模式(LaunchMode)
- 二分查找的迭代实现
- ACdream 1415 Important Roads(最短路&缩点&找桥)
- hbase集群安装和shell操作
- UI中常用的控件ImageView\Button
- 第六届蓝桥杯:黄金连分数
- Activity的四种启动模式
- Palindrome Number
- 权限对目录的重要性
- Win7系统自带的无线网络共享WIFI
- 力所能及之hibernate简单的增删查改
- 开源游戏引擎详解
- 6、R语言,调用自编函数
- 给定字符串,求出现次数最多的那个字母及次数,如有多个重复则都输出
- 流媒体一