类概述

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_TOP flag set, then the current activity will remain running and its Activity.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_TOP set, 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说明的更多相关文章

  1. Android LocalActivityManager的用法

    在开发中会碰到在一个activity中的局部(或者是activity的Fragment中)显示其他的activity 的内容,这时就用到了LocalActivityManager类. 假设这个容器是一 ...

  2. 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 错误. 总结一下发生错误的原因,一般的 ...

  3. Android 中常见控件的介绍和使用

    1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...

  4. 【Bugly安卓开发干货分享】Android APP 快速 Pad 化实现

    项目背景 采用最新版本手机 APP(之后称为 MyApp)代码,实现其 Pad 化,为平板和大屏手机用户提供更好的体验.为实现 MyApp 的 Pad 化工作,需要我们首先来了解一下 MyApp 项目 ...

  5. Android开发资源推荐第2季

    Android CPU监控想法,思路,核心技术和代码 Android App /Task/Stack 总体分析 http://www.eoeandroid.com/thread-161703-1-1. ...

  6. Android UI学习 - Tab的学习和使用(转)

      本文是参考Android官方提供的sample里面的ApiDemos的学习总结.   TabActivity   首先Android里面有个名为TabActivity来给我们方便使用.其中有以下可 ...

  7. 【读书笔记《Android游戏编程之从零开始》】6.Android 游戏开发常用的系统控件(TabHost、ListView)

    3.9 TabSpec与TabHost TabHost类官方文档地址:http://developer.android.com/reference/android/widget/TabHost.htm ...

  8. Android源码剖析之Framework层实战版(Ams管理Activity启动)

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 讲到实战,就不得不拿两个例子来说明,本篇想拿的是应用最广泛的两个:Ams和Wms,一个管理activ ...

  9. Android应用插件式开发解决方法

    转自:http://blog.csdn.net/arui319/article/details/8109650 一.现实需求描述 一般的,一个Android应用在开发到了一定阶段以后,功能模块将会越来 ...

随机推荐

  1. (九)ASP.NET自定义用户控件(2)

    http://www.cnblogs.com/SkySoot/archive/2012/09/04/2670678.html 用户控件 在 .NET 里,可以通过两种方式把自己的控件插入到 Web 窗 ...

  2. django中post方法和get方法的不同

    当我们提交表单仅仅需要获取数据时就可以用GET: 而当我们提交表单时需要更改服务器数据的状态,或者说发送e-mail,或者其他不仅仅是获取并显示数据的时候就使用POST. 在这个搜索书籍的例子里,我们 ...

  3. mysql 语句大全

    1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- 创建 备份 ...

  4. [原]HDU-1598-find the most comfortable road(暴力枚举+Kruskal最小生成树)

    题意: 给出一个图,然后Q个询问,每次询问从一个节点到另一个节点,联通图中的“最大边和最小边之差”的最小值,但如果节点之间不连通,则输出-1. 思路:由于询问Q < 11,m < 1000 ...

  5. MySQL 跳过同步错误方法

    最近MySQL 遇到了同步问题,现整理一下常遇到的错误的解决方法,备用. 方法一:手动设置动态参数 sql_slave_skip_counter 我常用的脚本: stop slave sql_thre ...

  6. Toast.makeText().show() 正常使用但不显示的解决办法

    症状: toast正常构造,调用show时,不显示. View tabMeItem = tabHost.findViewById(R.id.tab_me_xc); tabMeItem.setOnCli ...

  7. 视觉(3)blepo

    视觉(3)blepo 把matlab转成c程序有好办法了,从网上下载了一个函数库blepo,转换为c几乎是一行对一行,openCv经常涉及到的内存申请和释放这里都不用管.高兴!看看这段程序比较一下差别 ...

  8. 树&二叉树&二叉搜索树

    树&二叉树 树是由节点和边构成,储存元素的集合.节点分根节点.父节点和子节点的概念. 二叉树binary tree,则加了"二叉"(binary),意思是在树中作区分.每个 ...

  9. CSS之切出横幅

    简述 上节分享了clip-path来实现一个剪切横幅,本节通过另外一种方式来实现一个更经典的横幅. 简述 最终效果 小三角 效果 源码 阴影分割 效果 源码 合并 最终效果 我们先看一下最终要实现的效 ...

  10. UVa 247 Calling Circles【传递闭包】

    题意:给出n个人的m次电话,问最后构成多少个环,找出所有的环 自己想的是:用map来储存人名,每个人名映射成一个数字编号,再用并查集,求出有多少块连通块,输出 可是map不熟,写不出来,而且用并查集输 ...