android:launchMode概述
android:launchMode
An instruction on how the activity should be launched. There are four modes that work in conjunction with activity flags (FLAG_ACTIVITY_* constants) in Intent objects to determine what should happen when the activity is called upon to handle an intent. They are:
"standard"
"singleTop"
"singleTask"
"singleInstance" The default mode is "standard".
Activity有四种启动模式,默认为标准型。还是先给出表格,看的更加清楚。
| Use Cases | Launch Mode | Multiple Instances? | Comments |
| Normal launches for most activities | "standard" | Yes | Default. The system always creates a new instance of the activity in the target task and routes the intent to it. |
| "singleTop" | Conditionally | If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity. | |
| Specialized launches (not recommended for general use) | "singleTask" | No | The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one. |
| "singleInstance" | No | Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task. |
"standard"可以有多个相同实例,并且每次启动一个Activity,系统总是在任务栈中创建一个Activity新的实例并且为它设置意图的路径。
"singleTop"的多个实例是有条件的,如果一个Activity的实例已经存在与任务栈顶端,系统通过调用它的onNewIntent()函数来为意图设置到此实例的路径而非创建一个新的相同实例。
以上两个是常用的。
后两个不常用。
"singleTask"只有一个实例。在当前任务栈中,如果实例不存在,则会创建一个,如果这个Activity的实例已经存在,系统通过调用它的onNewIntent()函数来为意图设置到此实例的路径而非创建一个新的实例,即会结束它上面全部的Activity。如果另一个程序启动了这个Activity,并且此Activity已经在当前任务栈中创建,则不会在那个任务栈创建实例,而是使用引用指向当前任务栈中的实例。
例如:
B为singleTask模式
操作:A->B A->B->C A->B->C->B A->B->C->B->C->A A->B->C->B->C->A->B
实际:A->B A->B->C A->B A->B->C->A A->B
"singleInstance"Activity总是独占一个任务栈。如果A中启动B,系统为B另外开辟一个任务栈。
android:launchMode概述的更多相关文章
- android launchmode(四种启动模式)应用场景及实例
模式介绍 [1] standard 模式 这是默认模式,每次激活Activity时都会创建Activity实例,并放入任务栈中. [2] singleTop 模式 如果在任务的栈顶正好存在该Activ ...
- android:launchMode的四种方式
Activity一共有以下四种launchMode: standard singleTop singleTask singleInstance 1.standard standard模式是默认的启动模 ...
- [Learn Android Studio 汉化教程]第二章:Android Studio概述(一)
[Learn Android Studio ]第二章:Android Studio概述(一) Android Studio是一个视窗化的开发环境.为了充分利用有限的屏幕空间,不让你束手束脚,Andro ...
- android:launchMode="singleTask" 与 onNewIntent(Intent intent) 的用法
最近项目开发中用到了android:launchMode="singleTask" 和 onNewIntent(Intent intent)两个特性,现总结一下经验: androi ...
- Android数据加密概述及多种加密方式 聊天记录及账户加密 提供高质量的数据保护
Android数据加密概述及多种加密方式 聊天记录及账户加密 提供高质量的数据保护 数据加密又称password学,它是一门历史悠久的技术,指通过加密算法和加密密钥将明文转变为密文.而解密则是通过解密 ...
- android视图概述
android视图概述 一.简介 数据和控件分开的作用: 便于引用 便于修改:修改的时候直接改一次数据就可以了
- Android LaunchMode案例篇
首先感谢小伙伴的关注.然后祝愿广大的情侣们节日快乐! 在开发中有时会遇到这种场景,用户点击注冊.第一步,第二步,完毕注冊跳转到登录界面,不须要用户一步一步的返回到登录界面.这是怎么实现的呢? 案例:有 ...
- Android零基础入门第33节:Android事件处理概述
原文:Android零基础入门第33节:Android事件处理概述 通过对Android基本组件的学习,也有接触少部分Android的事件处理,比如按钮的点击事件.选框的状态切换事件. 一.Andro ...
- Android之android:launchMode
(本文转自:http://www.eoeandroid.com/blog-531377-3446.html) (详细查看:http://blog.csdn.net/liuhe688/article/d ...
随机推荐
- 使用VS连接SQLServe时提示未能载入文件或程序集“System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKey
解决方法: 就是去微软主页下载两个Microsoft SQL Server 2012补丁包,SQLSysClrTypes.msi和SharedManagementObjects.msi ...
- uC/OS-III学习2::uC/OS-III LED闪烁实验
1 前言: 看完了uC/OS-III的基本介绍之后,大致对这个操作系统有了点了解,但真正的理解还是要通过不断的去使用,在使用中体验uC/OS-III的乐趣和更深的理解其工作原理是非常重要的.因此,我在 ...
- 资源管理更新系统V2.0版的一些问题
1.在上传文件夹时现在只能传给吴缤进行上传,不够友好,也降低了上传速度, 办法:用C#写一个WINFORM程序,为用户提供上传功能,登录也使用JAVA提供的WEBSERVICE提供登录验证,然后选择一 ...
- 【C#】ASP.NET网页中添加单点登录功能
背景 首先,要说明的是,原先需求定义的是,同一个账号只能同时有一个人来登录,如果另外一个登录的话,前一个登陆者就自动被踢掉.本来原先要做成存储到服务器的数据库中,但是后来如果是非正常退出的话 下次就没 ...
- Swift - 初次使用:
今天Apple放出了新的编程语言.然后下载了Xcode6把系统升级到Mac OS 10.9.3 (Xcode6的系统最低要求). 创建了一个项目,折腾半天 都不知道怎么导入一个ViewControll ...
- android之BitmapFactory.Options的使用
怎样获取图片的大小? 首先我们把这个图片转成Bitmap,然后再利用Bitmap的getWidth()和getHeight()方法就可以取到图片的宽高了. 新问题又来了,在通过BitmapFactor ...
- 【译文】漫谈ASP.NET中的Session
最近这两天被一个Web Farm环境下的Session处理问题虐得很痛苦,网上到处找解决方案,在无意中翻看到这篇文章,感觉很不错,顺手查了一下,貌似没有现成的译文,于是一咬牙一跺脚把这篇文章翻译出来了 ...
- 0c-41-ARC下循环引用问题
1.ARC下循环引入问题 一个人拥有一只狗,一只狗拥有一个主人. 当增加d.owner = p;时形成循环引用. 解决方法:一端用strong,一端用weak. 2.ARC下@property参数 A ...
- JAVA设置SimpleDateFormat函数时区
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZo ...
- 教程:如何减小iOS应用程序的大小?
本文译自:Reducing the size of my App Q: 怎样才能让我的程序安装包小一点,让程序的下载和安装更快速? A: 本文收集了一些减小程序安装包大小的相关技巧(当第一次下载和安装 ...