类概述

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还有不从的界面组件。。。

转载于:https://www.cnblogs.com/wade-pcb/p/4646363.html

android LocalActivityManager说明相关推荐

  1. mysql去重合并字符串_Mysql将近两个月的记录合并为一行显示

    最近做报表统计,用到要求把近两个月的绩效作比较,并作出一些环比数据等. 场景:将1班同学的两个月的语文的平均成绩合并到一行比较. CREATE TABLE `Chinese_score` ( `id` ...

  2. 【转】Android Activity原理以及其子类描述,androidactivity

        Android Activity原理以及其子类描述,androidactivity 简介 Activity是Android应用程序组件,实现一个用户交互窗口,我们可以实现布局填充屏幕,也可以实 ...

  3. Android Tabhost with FragmentActivity

    此文解决我这两天的问题,故转载:原文Android Tabhost with FragmentActivity   2012-05-07 更新)接續Android TabHost中切換Activity ...

  4. 高大上的Android沉浸式状态栏?

    背景 之前做过Android沉浸式状态栏的相关需求,但是一直忙于工作,没时间系统的整理下沉浸式相关的知识,所以今天抽出时间,写一篇 Android沉浸式状态栏的文章. 何为沉浸式 沉浸式就是要给用户提 ...

  5. 【Android UI设计与开发】第06期:底部菜单栏(一)使用TabActivity实现底部菜单栏

    转载请注明出处:http://blog.csdn.net/yangyu20121224/article/details/8989063       从这一篇文章开始,我们将进入到一个应用程序主界面UI ...

  6. 分享几点Android 开发中的小技巧吧。不知道算不算?

    也不想多说多,就拿几点来给大家分享吧: Android 在XML里面共享同一布局文件 使用XML的方式为背景添加渐变的效果 如何用代码自定义Android 自动生成的标题? 在ActivityGrou ...

  7. Android应用插件式开发解决方法[转]

    一.现实需求描述 一般的,一个Android应用在开发到了一定阶段以后,功能模块将会越来越多,APK安装包也越来越大,用户在使用过程中也没有办法选择性的加载自己需要的功能模块.此时可能就需要考虑如何分 ...

  8. Android用shareUserID实现多个Activity显示在同一界面

    近来整理文档,发现两年前研究Android多个Activity叠加显示的方案.时光荏苒,一去不回. 虽然后来没有用上,但还是整理如下,Android版本还是2.2的: ActivityGroup描画方 ...

  9. 《移动项目实践》实验报告——Android组合控件

    实验目的 1.熟悉App开发常用的一些组合控件,主要包括底部标签栏的实现和用法.顶部导航栏的用法.横幅轮播条的实现和用法.循环视图3种布局的用法.材质设计库3种布局的用法等: 实验内容 仿淘宝主页 上 ...

  10. ActivityGroup中的子Activity创建Dialog:android.view.WindowManager$BadTokenException: U

    我们在ActivityGroup或者TabActivity中的子Activity创建Dialog若使用以下的代码 progressDialog = new ProgressDialog(XXX.thi ...

最新文章

  1. matplotlib如何绘制两点间连线_机器学习:Python常用库——Matplotlib库
  2. 对于python 3.x与python2.x中新型类的继承特性总结
  3. r 保留之前曲线_R简单数据处理和分析
  4. Android Context应用上下文详解
  5. matlab标准化出现负值,为什么我求出来的约束条件是负值
  6. Spark常见问题解决办法
  7. perl将字符串时间转换成 epoch time
  8. OFFICE技术讲座:标点压缩是各大OFFICE软件差异关键,总体考量有哪些
  9. 手机APP数据包抓包分析
  10. Web:6 大主流 Web 框架优缺点对比之Ember
  11. 你必须掌握的人生定律
  12. 计算机主机开机 风扇没有转动,电脑开机黑屏,电源风扇和CPU风扇都正常转动,但是显示器无任何显示,正常的一声滴,萤幕什么都不显示...
  13. CSS设置字间距、行间距、首行缩进
  14. 移动硬盘接android手机吗,笔点说:智能手机可以直接连接移动硬盘读取数据吗?...
  15. 论文笔记30 -- (视频压缩)【CVPR2021】FVC: A New Framework towards Deep Video Compression in Feature Space
  16. H.264笔记(接上节)
  17. json tobean
  18. 16路4-20mA转Modbus TCP网络数据采集模块 WJ89
  19. 三轴加速计数据计算倾斜角算法
  20. 【ADI高性能应用研讨会-长沙站】会议笔记记录

热门文章

  1. 农银电商项目学习笔记(一)
  2. Java基础--序列化和反序列化
  3. luaprofiler探索
  4. MyBatis+MySQL 返回插入的主键ID
  5. Mac/Windows Android Studio / Visual Studio Code/Eclipse /Xcode 操作 快捷键 :代码多行选中等 (开发利器)多
  6. 日记【2010-6-2】
  7. 201809-1 卖菜
  8. SQL简单基础(1)
  9. jQuery密码强度校验
  10. 同步异步和阻塞3-同步阻塞