android LocalActivityManager说明
类概述
Helper class for managing multiple running embedded activities in the same process. This class is not normally used directly, but rather created for you as part of theActivityGroup implementation.
首先说明一下,意思就是说这个类不能单独使用,只能在ActivityGroup里面使用。他的作用是管理多个正在运行的嵌入的activity的界面。。。
关于成员方法的说明:
其实看SDK也就可以知道了。。。
主要的就是派遣方法,让某一个操作可以作用于在这个ActivityGroup里面的Activity
| Window | destroyActivity(String id, boolean finish)
摧毁该ID的activity。。。。并且返回你删除的activity的view。。。Destroy the activity associated with a particular id.
|
| void | dispatchCreate(Bundle state)
Restore a state that was previously returned by
saveInstanceState(). |
| void | dispatchDestroy(boolean finishing)
Called by the container activity in its
onDestroy() so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| void | dispatchPause(boolean finishing)
Called by the container activity in its
onPause() so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| void | dispatchResume()
Called by the container activity in its
onResume() so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| void | dispatchStop()
Called by the container activity in its
onStop() so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| Activity | getActivity(String id)
Return the Activity object associated with a string ID.
|
| Activity | getCurrentActivity()
Retrieve the Activity that is currently running.
|
| String | getCurrentId()
Retrieve the ID of the activity that is currently running.
|
| void | removeAllActivities()
Remove all activities from this LocalActivityManager, performing an
onDestroy() on any that are currently instantiated. |
| Bundle | saveInstanceState()
Retrieve the state of all activities known by the group.
|
| Window | startActivity(String id, Intent intent)
Start a new activity running in the group.
|
下面主要说明一下startActivity(String id, Intent intent)这个方法:
Start a new activity running in the group. Every activity you start must have a unique string ID associated with it -- this is used to keep track of the activity, so that if you later call startActivity() again on it the same activity object will be retained.
When there had previously been an activity started under this id, it may either be destroyed and a new one started, or the current one re-used, based on these conditions, in order:
- If the Intent maps to a different activity component than is currently running, the current activity is finished and a new one started.
- If the current activity uses a non-multiple launch mode (such as singleTop), or the Intent has the
FLAG_ACTIVITY_SINGLE_TOPflag set, then the current activity will remain running and itsActivity.onNewIntent()method called. - If the new Intent is the same (excluding extras) as the previous one, and the new Intent does not have the
FLAG_ACTIVITY_CLEAR_TOPset, then the current activity will remain running as-is. - Otherwise, the current activity will be finished and a new one started.
If the given Intent can not be resolved to an available Activity, this method throws ActivityNotFoundException.
Warning: There is an issue where, if the Intent does not include an explicit component, we can restore the state for a different activity class than was previously running when the state was saved (if the set of available activities changes between those points).
参数
| id | Unique identifier of the activity to be started |
|---|---|
| intent | The Intent describing the activity to be started |
返回值
- Returns the window of the activity. The caller needs to take care of adding this window to a view hierarchy, and likewise dealing with removing the old window if the activity has changed.
简单的翻译一下就是:
新建并且运行一个activity在activitygroup里面,主要的说明就在这个String id里面,说尽量在新建时候不要是用同一个
id,因为这个样子就会到导致如果你使用再一次 startActivity() ,那么就会继续保留下去。。。
当这个activity需要被销毁的时候:
如果有以下的情况就可以不用销毁。其他都需要销毁。。。
1.已经有一个老的intent,而且新的intent没有使用FLAG_ACTIVITY_CLEAR_TOP 这个参数
2.当前的activity使用的是uses a non-multiple launch mode 的话
3.intent还有不从的界面组件。。。
android LocalActivityManager说明的更多相关文章
- Android LocalActivityManager的用法
在开发中会碰到在一个activity中的局部(或者是activity的Fragment中)显示其他的activity 的内容,这时就用到了LocalActivityManager类. 假设这个容器是一 ...
- android 使用Tabhost 发生could not create tab content because could not find view with id 错误
使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...
- Android 中常见控件的介绍和使用
1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...
- 【Bugly安卓开发干货分享】Android APP 快速 Pad 化实现
项目背景 采用最新版本手机 APP(之后称为 MyApp)代码,实现其 Pad 化,为平板和大屏手机用户提供更好的体验.为实现 MyApp 的 Pad 化工作,需要我们首先来了解一下 MyApp 项目 ...
- Android开发资源推荐第2季
Android CPU监控想法,思路,核心技术和代码 Android App /Task/Stack 总体分析 http://www.eoeandroid.com/thread-161703-1-1. ...
- Android UI学习 - Tab的学习和使用(转)
本文是参考Android官方提供的sample里面的ApiDemos的学习总结. TabActivity 首先Android里面有个名为TabActivity来给我们方便使用.其中有以下可 ...
- 【读书笔记《Android游戏编程之从零开始》】6.Android 游戏开发常用的系统控件(TabHost、ListView)
3.9 TabSpec与TabHost TabHost类官方文档地址:http://developer.android.com/reference/android/widget/TabHost.htm ...
- Android源码剖析之Framework层实战版(Ams管理Activity启动)
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 讲到实战,就不得不拿两个例子来说明,本篇想拿的是应用最广泛的两个:Ams和Wms,一个管理activ ...
- Android应用插件式开发解决方法
转自:http://blog.csdn.net/arui319/article/details/8109650 一.现实需求描述 一般的,一个Android应用在开发到了一定阶段以后,功能模块将会越来 ...
随机推荐
- TOMCAT服务器不写端口号、不写项目名访问项目、虚拟目录配置
一.不写端口. 这个问题都被问烂了,因为TOMCAT默认的访问端口为8080,而TCP/IP协议默认80端口访问,大家之所以看到别的网站都不写端口号是因为人家用的的80端口访问的,而80端口因为的TC ...
- OpenGL基础渲染
客户端-服务器 客户端是存储在CPU存储器中的,并且在应用程序中执行(或者驱动程序),驱动程序将渲染命令和数据组合起来,发动到服务器执行.服务器和客户机在功能上是异步的,他们是各自独立的软件模块或者硬 ...
- hbase 学习笔记二----shell
Hbase 是一个分布式的.面向列的开源数据库,其实现是建立在google 的bigTable 理论之上,并基于hadoop HDFS文件系统. Hbase不同于一般的关系型数据库 ...
- TCP连接探测中的Keepalive 和心跳包
采用TCP连接的C/S模式软件,连接的双方在连接空闲状态时,如果任意一方意外崩溃.当机.网线断开或路由器故障,另一方无法得知TCP连接已经失效,除非继续在此连接上发送数据导致错误返回.很多时候,这不是 ...
- sizeof()与strlen()的区别
首先需要说明的是sizeof和strlen都可以求长度,但是却有很大的区别,简单来说可以概括为以下几点: 1.sizeof是一个关键字,而strlen确实一个函数. 2.sizeof求的是字节长度,而 ...
- 51nod1678 lyk与gcd
容斥定理所以可以用莫比乌斯函数来搞.逆向思维答案等于总和减去和他互质的.那么设f[i]=∑a[j] i|j.ans[i]=sum- ∑mo[j]*f[j] 跟bzoj2440那道题挺像的都是利用莫比乌 ...
- OE中admin的内置帐号
在OE中admin的内置帐号为SUPERUSER_ID,可以用来直接做判断登录用户是否admin from openerp import SUPERUSER_ID if uid == SUPERUSE ...
- o4.数组指针和指针数组的区别
------- android培训.iOS培训.期待与您交流! ---------- 我们看一下数组指针和指针数组: 数组指针(也称行指针)定义 int (*p)[n];()优先级高,首先说明p是一个 ...
- RAC 之 RMAN 恢复
RAC 下的RMAN 讲究的是备份和还原的策略要一致.备份策略的不同,会导致备份结果的分步不同,进而影响恢复的策略和步骤.一般情况下,恢复策略和备份策略必须是对应的.如果备份策略进行了修改,那么恢复也 ...
- 配置Linux 11G R2 RAC NTP服务
安装Oracle 11g RAC时,我们需要配置ntp服务.在使用虚拟机的情况下对于时钟同步方式的配置有很多种方式,可以使用vmware自带的时钟同步功能,也可以直接将本地的一个节点用作时间服务器.本 ...