Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 13](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/LocalActivityManager#pubctors) \| [Methods](https://developer.android.com/reference/android/app/LocalActivityManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/LocalActivityManager#inhmethods)

# LocalActivityManager

*** ** * ** ***

` public class LocalActivityManager `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.LocalActivityManager |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 13.**   

Use the new `https://developer.android.com/reference/android/app/Fragment` and `https://developer.android.com/reference/android/app/FragmentManager` APIs instead; these are also available on older platforms through the Android compatibility package.

<br />

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 the `https://developer.android.com/reference/android/app/ActivityGroup` implementation.
**See also:**

- `https://developer.android.com/reference/android/app/ActivityGroup`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/LocalActivityManager#LocalActivityManager(android.app.Activity,%20boolean)(https://developer.android.com/reference/android/app/Activity parent, boolean singleMode) ` Create a new LocalActivityManager for holding activities running within the given <var translate="no">parent</var>. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/Window` | ` https://developer.android.com/reference/android/app/LocalActivityManager#destroyActivity(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String id, boolean finish) ` Destroy the activity associated with a particular id. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#dispatchCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle state) ` Restore a state that was previously returned by `https://developer.android.com/reference/android/app/LocalActivityManager#saveInstanceState()`. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#dispatchDestroy(boolean)(boolean finishing) ` Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onDestroy()` so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#dispatchPause(boolean)(boolean finishing) ` Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onPause()` so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#dispatchResume()() ` Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onResume()` so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#dispatchStop()() ` Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onStop()` so that LocalActivityManager can perform the corresponding action on the activities it holds. |
| ` https://developer.android.com/reference/android/app/Activity` | ` https://developer.android.com/reference/android/app/LocalActivityManager#getActivity(java.lang.String)(https://developer.android.com/reference/java/lang/String id) ` Return the Activity object associated with a string ID. |
| ` https://developer.android.com/reference/android/app/Activity` | ` https://developer.android.com/reference/android/app/LocalActivityManager#getCurrentActivity()() ` Retrieve the Activity that is currently running. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/LocalActivityManager#getCurrentId()() ` Retrieve the ID of the activity that is currently running. |
| ` void` | ` https://developer.android.com/reference/android/app/LocalActivityManager#removeAllActivities()() ` Remove all activities from this LocalActivityManager, performing an `https://developer.android.com/reference/android/app/Activity#onDestroy()` on any that are currently instantiated. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/app/LocalActivityManager#saveInstanceState()() ` Retrieve the state of all activities known by the group. |
| ` https://developer.android.com/reference/android/view/Window` | ` https://developer.android.com/reference/android/app/LocalActivityManager#startActivity(java.lang.String,%20android.content.Intent)(https://developer.android.com/reference/java/lang/String id, https://developer.android.com/reference/android/content/Intent intent) ` Start a new activity running in the group. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### LocalActivityManager

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public LocalActivityManager (Activity parent, 
                boolean singleMode)
```

Create a new LocalActivityManager for holding activities running within the given <var translate="no">parent</var>.

<br />

| Parameters ||
|---|---|
| `parent` | `Activity`: the host of the embedded activities <br /> |
| `singleMode` | `boolean`: True if the LocalActivityManger should keep a maximum of one activity resumed <br /> |

## Public methods

### destroyActivity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Window destroyActivity (String id, 
                boolean finish)
```

Destroy the activity associated with a particular id. This activity will go through the normal lifecycle events and fine onDestroy(), and then the id removed from the group.

<br />

| Parameters ||
|---|---|
| `id` | `String`: Unique identifier of the activity to be destroyed <br /> |
| `finish` | `boolean`: If true, this activity will be finished, so its id and all state are removed from the group. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/Window` | Returns the window that was used to display the activity, or null if there was none. <br /> |

### dispatchCreate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dispatchCreate (Bundle state)
```

Restore a state that was previously returned by `https://developer.android.com/reference/android/app/LocalActivityManager#saveInstanceState()`. This adds to the activity group information about all activity IDs that had previously been saved, even if they have not been started yet, so if the user later navigates to them the correct state will be restored.

Note: This does **not** change the current running activity, or start whatever activity was previously running when the state was saved. That is up to the client to do, in whatever way it thinks is best.

<br />

| Parameters ||
|---|---|
| `state` | `Bundle`: a previously saved state; does nothing if this is null <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/LocalActivityManager#saveInstanceState()`

### dispatchDestroy

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dispatchDestroy (boolean finishing)
```

Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onDestroy()` so that LocalActivityManager can perform the corresponding action on the activities it holds.

<br />

| Parameters ||
|---|---|
| `finishing` | `boolean` <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Activity#onDestroy()`

### dispatchPause

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dispatchPause (boolean finishing)
```

Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onPause()` so that LocalActivityManager can perform the corresponding action on the activities it holds.

<br />

| Parameters ||
|---|---|
| `finishing` | `boolean`: set to true if the parent activity has been finished; this can be determined by calling Activity.isFinishing() <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Activity#onPause()`
- `https://developer.android.com/reference/android/app/Activity#isFinishing()`

### dispatchResume

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dispatchResume ()
```

Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onResume()` so that LocalActivityManager can perform the corresponding action on the activities it holds.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/Activity#onResume()`

### dispatchStop

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dispatchStop ()
```

Called by the container activity in its `https://developer.android.com/reference/android/app/Activity#onStop()` so that LocalActivityManager can perform the corresponding action on the activities it holds.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/Activity#onStop()`

### getActivity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Activity getActivity (String id)
```

Return the Activity object associated with a string ID.

<br />

| Parameters ||
|---|---|
| `id` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Activity` | the associated Activity object, or null if the id is unknown or its activity is not currently instantiated <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/LocalActivityManager#startActivity(java.lang.String,%20android.content.Intent)`

### getCurrentActivity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Activity getCurrentActivity ()
```

Retrieve the Activity that is currently running.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Activity` | the currently running (resumed) Activity, or null if there is not one <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/LocalActivityManager#startActivity(java.lang.String,%20android.content.Intent)`
- `https://developer.android.com/reference/android/app/LocalActivityManager#getCurrentId()`

### getCurrentId

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getCurrentId ()
```

Retrieve the ID of the activity that is currently running.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the ID of the currently running (resumed) Activity, or null if there is not one <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/LocalActivityManager#startActivity(java.lang.String,%20android.content.Intent)`
- `https://developer.android.com/reference/android/app/LocalActivityManager#getCurrentActivity()`

### removeAllActivities

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removeAllActivities ()
```

Remove all activities from this LocalActivityManager, performing an `https://developer.android.com/reference/android/app/Activity#onDestroy()` on any that are currently instantiated.

<br />

### saveInstanceState

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle saveInstanceState ()
```

Retrieve the state of all activities known by the group. For activities that have previously run and are now stopped or finished, the last saved state is used. For the current running activity, its `https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle)` is called to retrieve its current state.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle holding the newly created state of all known activities <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/LocalActivityManager#dispatchCreate(android.os.Bundle)`

### startActivity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Window 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 `https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_SINGLE_TOP` flag set, then the current activity will remain running and its `https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)` method called.
- If the new Intent is the same (excluding extras) as the previous one, and the new Intent does not have the `https://developer.android.com/reference/android/content/Intent#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 `https://developer.android.com/reference/android/content/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).

<br />

| Parameters ||
|---|---|
| `id` | `String`: Unique identifier of the activity to be started <br /> |
| `intent` | `Intent`: The Intent describing the activity to be started <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/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. <br /> |

| Throws ||
|---|---|
|   | android.content.ActivityNotFoundException |