类概述

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 theActivityGroupimplementation.


首先说明一下,意思就是说这个类不能单独使用,只能在ActivityGroup里面使用。他的作用是管理多个正在运行的嵌入的activity的界面。。。


关于成员方法的说明:

其实看SDK也就可以知道了。。。

主要的就是派遣方法,让某一个操作可以作用于在这个ActivityGroup里面的Activity

Window destroyActivity( Stringid, boolean finish) 摧毁该ID的activity。。。。并且返回你删除的activity的view。。。Destroy the activity associated with a particular id.
void dispatchCreate( Bundlestate) 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( Stringid) 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( Stringid, Intentintent) Start a new activity running in the group.

下面主要说明一下startActivity(Stringid,Intentintent)这个方法:

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 theFLAG_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 theFLAG_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 throwsActivityNotFoundException.

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


更多相关文章

  1. Android和IOS录制mp3语音文件的方法
  2. Android中多层Fragment嵌套,调用相册返回Uri无法显示图片的问题解
  3. android 保持屏幕长亮及解锁的方法
  4. Android获取屏幕宽高的方法
  5. 禁止Activity+ EditText 界面默认弹出键盘
  6. android 输入法界面显示的开关
  7. Android Service Bind启动调用service方法
  8. Android 欢迎界面淡出动画效果(Animation)
  9. 【移动安全】Android App Smail代码动态跟踪调试方法

随机推荐

  1. 一个打通jni,java framework,application三
  2. Android Activity切换动画效果详解(附源代
  3. [Gradle for Android 笔记系列]二 、Pack
  4. adb server is out of date. killing
  5. Android帧缓冲区(Frame Buffer)硬件抽象层(H
  6. android studio 编译加速
  7. Android(安卓)单选之史上最简单的ListVie
  8. android实现自定义相机以及图片的水印
  9. android设置edittext光标的颜色
  10. Android通过OpenSL ES播放音频套路详解