Most visited

Recently visited

Added in API level 1
Deprecated since API level 13

LocalActivityManager

public class LocalActivityManager
extends Object

java.lang.Object
   ↳ android.app.LocalActivityManager


此类在API级别13中已被弃用。
改为使用新的FragmentFragmentManager API; 这些也可以通过Android兼容性套件在较早的平台上使用。

帮助程序类用于在同一进程中管理多个正在运行的嵌入式活动。 这个类通常不是直接使用,而是作为ActivityGroup实现的一部分为您创建的。

也可以看看:

Summary

Public constructors

LocalActivityManager(Activity parent, boolean singleMode)

创建一个新的LocalActivityManager用于保存在给定 父级内运行的活动。

Public methods

Window destroyActivity(String id, boolean finish)

销毁与特定ID关联的活动。

void dispatchCreate(Bundle state)

还原以前由 saveInstanceState()返回的 saveInstanceState()

void dispatchDestroy(boolean finishing)

onDestroy()的容器活动调用,以便LocalActivityManager可以对其 onDestroy()活动执行相应的操作。

void dispatchPause(boolean finishing)

onPause()的容器活动调用,以便LocalActivityManager可以对其保存的活动执行相应的操作。

void dispatchResume()

onResume()的容器活动调用,以便LocalActivityManager可以对其包含的活动执行相应的操作。

void dispatchStop()

onStop()的容器活动调用,以便LocalActivityManager可以对其拥有的活动执行相应的操作。

Activity getActivity(String id)

返回与字符串ID关联的Activity对象。

Activity getCurrentActivity()

检索当前正在运行的活动。

String getCurrentId()

检索当前正在运行的活动的ID。

void removeAllActivities()

删除此LocalActivityManager中的所有活动,对当前实例化的任何活动执行 onDestroy()

Bundle saveInstanceState()

检索该组已知的所有活动的状态。

Window startActivity(String id, Intent intent)

开始在该组中运行的新活动。

Inherited methods

From class java.lang.Object

Public constructors

LocalActivityManager

Added in API level 1
LocalActivityManager (Activity parent, 
                boolean singleMode)

创建一个新的LocalActivityManager用于保存在给定 父级内运行的活动。

Parameters
parent Activity: the host of the embedded activities
singleMode boolean: True if the LocalActivityManger should keep a maximum of one activity resumed

Public methods

destroyActivity

Added in API level 1
Window destroyActivity (String id, 
                boolean finish)

销毁与特定ID关联的活动。 此活动将通过正常的生命周期事件并罚款onDestroy(),然后从组中删除该ID。

Parameters
id String: Unique identifier of the activity to be destroyed
finish boolean: If true, this activity will be finished, so its id and all state are removed from the group.
Returns
Window Returns the window that was used to display the activity, or null if there was none.

dispatchCreate

Added in API level 1
void dispatchCreate (Bundle state)

恢复以前由saveInstanceState()返回的saveInstanceState() 这会在活动组中添加有关以前保存的所有活动ID的信息,即使它们尚未启动也是如此,因此如果用户稍后导航到其中,则会恢复正确的状态。

注意:这不会改变当前运行的活动,或启动任何活动之前运行保存时的状态。 这取决于客户做什么,无论它认为最好。

Parameters
state Bundle: a previously saved state; does nothing if this is null

也可以看看:

dispatchDestroy

Added in API level 1
void dispatchDestroy (boolean finishing)

onDestroy()的容器活动调用,以便LocalActivityManager可以对其拥有的活动执行相应的操作。

Parameters
finishing boolean

也可以看看:

dispatchPause

Added in API level 1
void dispatchPause (boolean finishing)

onPause()的容器活动调用,以便LocalActivityManager可以对其拥有的活动执行相应的操作。

Parameters
finishing boolean: set to true if the parent activity has been finished; this can be determined by calling Activity.isFinishing()

也可以看看:

dispatchResume

Added in API level 1
void dispatchResume ()

onResume()的容器活动调用,以便LocalActivityManager可以对其拥有的活动执行相应的操作。

也可以看看:

dispatchStop

Added in API level 1
void dispatchStop ()

onStop()的容器活动调用,以便LocalActivityManager可以对其拥有的活动执行相应的操作。

也可以看看:

getActivity

Added in API level 1
Activity getActivity (String id)

返回与字符串ID关联的Activity对象。

Parameters
id String
Returns
Activity the associated Activity object, or null if the id is unknown or its activity is not currently instantiated

也可以看看:

getCurrentActivity

Added in API level 1
Activity getCurrentActivity ()

检索当前正在运行的活动。

Returns
Activity the currently running (resumed) Activity, or null if there is not one

也可以看看:

getCurrentId

Added in API level 1
String getCurrentId ()

检索当前正在运行的活动的ID。

Returns
String the ID of the currently running (resumed) Activity, or null if there is not one

也可以看看:

removeAllActivities

Added in API level 1
void removeAllActivities ()

删除此LocalActivityManager中的所有活动,对当前实例化的任何活动执行 onDestroy()

saveInstanceState

Added in API level 1
Bundle saveInstanceState ()

检索该组已知的所有活动的状态。 对于先前已运行且现在已停止或已完成的活动,将使用上次保存的状态。 对于当前正在运行的活动,将调用其onSaveInstanceState(Bundle)以检索其当前状态。

Returns
Bundle a Bundle holding the newly created state of all known activities

也可以看看:

startActivity

Added in API level 1
Window startActivity (String id, 
                Intent intent)

开始在该组中运行的新活动。 您开始的每个活动都必须具有与其关联的唯一字符串ID - 用于跟踪活动,以便如果稍后再次调用startActivity(),则会保留相同的活动对象。

如果之前已经有一个以此ID开始的活动,则可以根据这些条件按照以下顺序将其销毁并开始新活动,或者重新使用当前活动:

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

如果给定的Intent无法解析为可用的活动,则此方法将抛出 ActivityNotFoundException

警告:如果Intent不包含显式组件,那么我们可以恢复与保存状态时(如果可用活动集在这些点之间更改时)之前运行的不同活动类的状态。

Parameters
id String: Unique identifier of the activity to be started
intent Intent: The Intent describing the activity to be started
Returns
Window 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.
Throws
ActivityNotFoundException

Hooray!