Android的Intent.FLAG_ACTIVITY_CLEAR_TOP无效
转载:http://blog.csdn.net/u011361576/article/details/48626237
今天写代码遇到了一个问题:
当 B - A - B 跳转的时候,使用Intent的FLAG_ACTIVITY_CLEAR_TOP会让第一个B和第二个A,destory掉,但是当B - A - C跳转的时候不会调用B和A的destory。
查看API文档才发现原因,所以这里记录一下避免下次忘记了:
public static final int FLAG_ACTIVITY_CLEAR_TOP
If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.
如果设置这个属性,是当要启动的Activity已经存在当前Task中,才会在启动的时候销毁其他的Activity。
所以上面当A跳C的时候不满足此条件。
当然如果想实现这个效果可以使用:
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
不过此方法要求最低API为11
Android的Intent.FLAG_ACTIVITY_CLEAR_TOP无效的更多相关文章
- 【转】Android 关闭多个视图Intent.FLAG_ACTIVITY_CLEAR_TOP用法
如果已经启动了四个Activity:A,B,C和D.在D Activity里,我们要跳到B Activity,同时希望C finish掉, 可以在startActivity(intent)里的inte ...
- ActivityGroup相关--getLocalActivityManager() 以及intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)用法
ActivityGroup简介 1.ActivityGroup的核心就是继承了该类,能够通过getLocalActivityManager()得到一个LocalActivityManager 如,Lo ...
- Android解决Intent中的数据重复问题
转载地址:http://www.cnblogs.com/anrainie/articles/2383941.html 最近在研究Android,遇到了一些Notification(通知)的问题: .N ...
- 【转】【Java/Android】Intent的简介以及属性的详解
一.Intent的介绍 Intent的中文意思是“意图,意向”,在Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述 ...
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)用法
如果已经启动了四个Activity:A,B,C和D.在D Activity里,我们要跳到B Activity,同时希望C finish掉,可以在startActivity(intent)里的inten ...
- Activity: launchMode 和 Intent.FLAG_ACTIVITY_CLEAR_TOP
Activity 的 launchMode: 1. standard: 标准模式 这种启动模式为标准模式,也是默认模式.每当我们启动一个Activity,系统就会相应的创建一个实例,不管这个实例是否已 ...
- Android 笔记 Intent and Bundle day7
学习了Intent与Bundle的使用,进行应用中的交互 package com.example.intent; import android.app.Activity; import android ...
- Android 通过 Intent 传递类对象或list对象
(转:http://www.cnblogs.com/shaocm/archive/2013/01/08/2851248.html) Android中Intent传递类对象提供了两种方式一种是 通过实现 ...
- ActivityGroup、TabHost之子页面不刷新——getLocalActivityManager() 以及intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)用法
TabHost继承自ActivityGroup,以下不再单独列出. ActivityGroup在第一次创建的时候会完整的执行子Activity或子view的生命周期,但在从其他子activity或子v ...
随机推荐
- 4种解决json日期格式问题的办法
4种解决json日期格式问题的办法 开发中有时候需要从服务器端返回json格式的数据,在后台代码中如果有DateTime类型的数据使用系统自带的工具类序列化后将得到一个很长的数字表示日期数据,如下 ...
- 21-Python-Django进阶补充篇
1. 路由部分补充 1.1 默认值 url: url(r'^index/', views.index, {'name': 'root'}), views: def index(request,name ...
- [LeetCode] Nested List Weight Sum 嵌套链表权重和
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- 将HTML5封装成android应用APK文件的几种方法
越来越多的开发者热衷于使用html5+JavaScript开发移动Web App.不过,HTML5 Web APP的出现能否在未来取代移动应用,就目前来说,还是个未知数.一方面,用户在使用习惯上,不喜 ...
- 外网访问内网工具ngrok tunnel 使用总结
需求分析 在软件开发测试过程中,我们会经常遇到需要网站部署测试.给客户演示.APP开发的调试这样的需求.通常的做法是申请一个域名和空间,将网站放到外网上给客户演示. 这种方法确实可行不过会有两点不好, ...
- ACM模板(持续补完)
1.KMP #include<cstring> #include<algorithm> #include<cstdio> using namespace std; ...
- dubbo 配置解析
1.dubbo 常用配置 <dubbo:service/> 服务配置,用于暴露一个服务,定义服务的元信息,一个服务可以用多个协议暴露,一个服务也可以注册到多个注册中心.eg.<dub ...
- 关于FloatingActionButton
由于FloatingActionButton本质上是ImageView,跟ImageView相关的就不介绍,这里重点介绍新加的几个属性. app:fabSize:FloatingActionButto ...
- C#操作图片帮助类
using System; using System.Collections; using System.IO; using System.Drawing; using System.Drawing. ...
- java 中正则表达式匹配
String str = "#a#,#b#"; String reg="\\#+[^\\#]+\\#+"; Pattern p=Pattern.compile( ...