Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/app/ActivityManager#nestedclasses) \| [Constants](https://developer.android.com/reference/android/app/ActivityManager#constants) \| [Methods](https://developer.android.com/reference/android/app/ActivityManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/ActivityManager#inhmethods)

# ActivityManager

*** ** * ** ***


`
public


class
ActivityManager
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

<br />


This class gives information about, and interacts
with, activities, services, and the containing
process.


A number of the methods in this class are for
debugging or informational purposes and they should
not be used to affect any runtime behavior of
your app. These methods are called out as such in
the method level documentation.


Most application developers should not have the need to
use this class, most of whose methods are for specialized
use cases. However, a few methods are more broadly applicable.
For instance, `https://developer.android.com/reference/android/app/ActivityManager#isLowRamDevice()`
enables your app to detect whether it is running on a low-memory device,
and behave accordingly.
`https://developer.android.com/reference/android/app/ActivityManager#clearApplicationUserData()`
is for apps with reset-data functionality.


In some special use cases, where an app interacts with
its Task stack, the app may use the
`https://developer.android.com/reference/android/app/ActivityManager.AppTask` and
`https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo` inner
classes. However, in general, the methods in this class should
be used for testing and debugging purposes only.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.AppTask` The AppTask allows you to manage your own application's tasks. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.MemoryInfo` Information you can retrieve about the available memory through `https://developer.android.com/reference/android/app/ActivityManager#getMemoryInfo(android.app.ActivityManager.MemoryInfo)`. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo` Information you can retrieve about any processes that are in an error condition. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo` Information you can retrieve about tasks that the user has most recently started or visited. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo` Information you can retrieve about a running process. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo` Information you can retrieve about a particular Service that is currently running in the system. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo` Information you can retrieve about a particular task that is currently "running" in the system. |
| ` class` | `https://developer.android.com/reference/android/app/ActivityManager.TaskDescription` Information you can set and retrieve about the current activity within the recent task list. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/ActivityManager#ACTION_REPORT_HEAP_LIMIT` Action an app can implement to handle reports from `https://developer.android.com/reference/android/app/ActivityManager#setWatchHeapLimit(long)`. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_LOCKED` Full lock task mode is active. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_NONE` Lock task mode is not active. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_PINNED` App pinning mode is active. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/ActivityManager#META_HOME_ALTERNATE` [`<meta-data>`](https://developer.android.com/guide/topics/manifest/meta-data-element) name for a 'home' Activity that declares a package that is to be uninstalled in lieu of the declaring one. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_NO_USER_ACTION` Flag for `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int)`: don't count this as a user-instigated action, so the current activity will not receive a hint that the user is leaving. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_WITH_HOME` Flag for `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int)`: also move the "home" activity along with the task, so it is positioned immediately behind the task. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#RECENT_IGNORE_UNAVAILABLE` Provides a list that does not contain any recent tasks that currently are not available to the user. |
| `int` | `https://developer.android.com/reference/android/app/ActivityManager#RECENT_WITH_EXCLUDED` Flag for use with `https://developer.android.com/reference/android/app/ActivityManager#getRecentTasks(int,%20int)`: return all tasks, even those that have set their `https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS` flag. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#addAppTask(android.app.Activity,%20android.content.Intent,%20android.app.ActivityManager.TaskDescription,%20android.graphics.Bitmap)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/app/ActivityManager.TaskDescription description, https://developer.android.com/reference/android/graphics/Bitmap thumbnail) ` Add a new `https://developer.android.com/reference/android/app/ActivityManager.AppTask` for the calling application. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#addApplicationStartInfoCompletionListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.ApplicationStartInfo>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/app/ApplicationStartInfo> listener) ` Adds a callback that is notified when the `https://developer.android.com/reference/android/app/ApplicationStartInfo` record of this startup is complete. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#addStartInfoTimestamp(int,%20long)(int key, long timestampNs) ` Adds an optional developer supplied timestamp to the calling apps most recent `https://developer.android.com/reference/android/app/ApplicationStartInfo`. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#appNotResponding(java.lang.String)(https://developer.android.com/reference/java/lang/String reason) ` Method for the app to tell system that it's wedged and would like to trigger an ANR. |
| ` boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#clearApplicationUserData()() ` Permits an application to erase its own data from disk. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#clearWatchHeapLimit()() ` Clear a heap watch limit previously set by `https://developer.android.com/reference/android/app/ActivityManager#setWatchHeapLimit(long)`. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#dumpPackageState(java.io.FileDescriptor,%20java.lang.String)(https://developer.android.com/reference/java/io/FileDescriptor fd, https://developer.android.com/reference/java/lang/String packageName) ` Perform a system dump of various state associated with the given application package name. |
| ` https://developer.android.com/reference/android/util/Size` | ` https://developer.android.com/reference/android/app/ActivityManager#getAppTaskThumbnailSize()() ` Return the current design dimensions for `https://developer.android.com/reference/android/app/ActivityManager.AppTask` thumbnails, for use with `https://developer.android.com/reference/android/app/ActivityManager#addAppTask(android.app.Activity,%20android.content.Intent,%20android.app.ActivityManager.TaskDescription,%20android.graphics.Bitmap)`. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.AppTask>` | ` https://developer.android.com/reference/android/app/ActivityManager#getAppTasks()() ` Get the list of tasks associated with the calling application. |
| ` https://developer.android.com/reference/android/content/pm/ConfigurationInfo` | ` https://developer.android.com/reference/android/app/ActivityManager#getDeviceConfigurationInfo()() ` Get the device configuration attributes. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ApplicationExitInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getHistoricalProcessExitReasons(java.lang.String,%20int,%20int)(https://developer.android.com/reference/java/lang/String packageName, int pid, int maxNum) ` Return a list of `https://developer.android.com/reference/android/app/ApplicationExitInfo` records containing the reasons for the most recent app deaths. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ApplicationStartInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getHistoricalProcessStartReasons(int)(int maxNum) ` Return a list of `https://developer.android.com/reference/android/app/ApplicationStartInfo` records containing the information about the most recent app startups. |
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#getLargeMemoryClass()() ` Return the approximate per-application memory class of the current device when an application is running with a large heap. |
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#getLauncherLargeIconDensity()() ` Get the preferred density of icons for the launcher. |
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#getLauncherLargeIconSize()() ` Get the preferred launcher icon size. |
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#getLockTaskModeState()() ` Return the current state of task locking. |
| ` int` | ` https://developer.android.com/reference/android/app/ActivityManager#getMemoryClass()() ` Return the approximate per-application memory class of the current device. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#getMemoryInfo(android.app.ActivityManager.MemoryInfo)(https://developer.android.com/reference/android/app/ActivityManager.MemoryInfo outInfo) ` Return general information about the memory state of the system. |
| ` static void` | ` https://developer.android.com/reference/android/app/ActivityManager#getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo)(https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo outState) ` Return global memory state information for the calling process. |
| ` https://developer.android.com/reference/android/os/Debug.MemoryInfo` | ` https://developer.android.com/reference/android/app/ActivityManager#getProcessMemoryInfo(int[])(int[] pids) ` Return information about the memory usage of one or more processes. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getProcessesInErrorState()() ` Returns a list of any processes that are currently in an error condition. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getRecentTasks(int,%20int)(int maxNum, int flags) ` *This method was deprecated in API level 21. As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#LOLLIPOP`, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see `https://developer.android.com/reference/android/app/ActivityManager#getAppTasks()` for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.* |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getRunningAppProcesses()() ` Returns a list of application processes that are running on the device. |
| ` https://developer.android.com/reference/android/app/PendingIntent` | ` https://developer.android.com/reference/android/app/ActivityManager#getRunningServiceControlPanel(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName service) ` Returns a PendingIntent you can start to show a control panel for the given running service. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getRunningServices(int)(int maxNum) ` *This method was deprecated in API level 26. As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, this method is no longer available to third party applications. For backwards compatibility, it will still return the caller's own services.* |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo>` | ` https://developer.android.com/reference/android/app/ActivityManager#getRunningTasks(int)(int maxNum) ` *This method was deprecated in API level 21. As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#LOLLIPOP`, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak person information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks, and possibly some other tasks such as home that are known to not be sensitive.* |
| ` boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isActivityStartAllowedOnDisplay(android.content.Context,%20int,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, int displayId, https://developer.android.com/reference/android/content/Intent intent) ` Check if the context is allowed to start an activity on specified display. |
| ` boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isBackgroundRestricted()() ` Query whether the user has enabled background restrictions for this app. |
| ` boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isInLockTaskMode()() ` *This method was deprecated in API level 23. Use `https://developer.android.com/reference/android/app/ActivityManager#getLockTaskModeState()` instead.* |
| ` static boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isLowMemoryKillReportSupported()() ` |
| ` boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isLowRamDevice()() ` Returns true if this is a low-RAM device. |
| ` static boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isRunningInTestHarness()() ` *This method was deprecated in API level 29. this method is false for all user builds. Users looking to check if their device is running in a device farm should see `https://developer.android.com/reference/android/app/ActivityManager#isRunningInUserTestHarness()`.* |
| ` static boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isRunningInUserTestHarness()() ` Returns "true" if the device is running in Test Harness Mode. |
| ` static boolean` | ` https://developer.android.com/reference/android/app/ActivityManager#isUserAMonkey()() ` Returns "true" if the user interface is currently being messed with by a [monkey](https://developer.android.com/studio/test/other-testing-tools/monkey). |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#killBackgroundProcesses(java.lang.String)(https://developer.android.com/reference/java/lang/String packageName) ` Have the system immediately kill all background processes associated with the given package. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int,%20android.os.Bundle)(int taskId, int flags, https://developer.android.com/reference/android/os/Bundle options) ` Ask that the task associated with a given task ID be moved to the front of the stack, so it is now visible to the user. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int)(int taskId, int flags) ` Equivalent to calling `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int,%20android.os.Bundle)` with a null options argument. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#registerAnrWarningListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.AnrWarningResult>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/app/AnrWarningResult> listener) ` Registers a listener that is called when the app is close to the ANR timeout. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#removeApplicationStartInfoCompletionListener(java.util.function.Consumer<android.app.ApplicationStartInfo>)(https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/app/ApplicationStartInfo> listener) ` Removes the provided callback set by `https://developer.android.com/reference/android/app/ActivityManager#addApplicationStartInfoCompletionListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.ApplicationStartInfo>)`. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#restartPackage(java.lang.String)(https://developer.android.com/reference/java/lang/String packageName) ` *This method was deprecated in API level 15. This is now just a wrapper for `https://developer.android.com/reference/android/app/ActivityManager#killBackgroundProcesses(java.lang.String)`; the previous behavior here is no longer available to applications because it allows them to break other applications by removing their alarms, stopping their services, etc.* |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#setProcessStateSummary(byte[])(byte[] state) ` Set custom state data for this process. |
| ` static void` | ` https://developer.android.com/reference/android/app/ActivityManager#setVrThread(int)(int tid) ` Enable more aggressive scheduling for latency-sensitive low-runtime VR threads. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#setWatchHeapLimit(long)(long pssSize) ` Request that the system start watching for the calling process to exceed a pss size as given here. |
| ` void` | ` https://developer.android.com/reference/android/app/ActivityManager#unregisterAnrWarningListener(java.util.function.Consumer<android.app.AnrWarningResult>)(https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/app/AnrWarningResult> listener) ` Unregisters a previously registered ANR warning listener. |

| ### 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*. | ||

## Constants

### ACTION_REPORT_HEAP_LIMIT

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

```
public static final String ACTION_REPORT_HEAP_LIMIT
```

Action an app can implement to handle reports from `https://developer.android.com/reference/android/app/ActivityManager#setWatchHeapLimit(long)`.
If your package has an activity handling this action, it will be launched with the
heap data provided to it the same way as `https://developer.android.com/reference/android/content/Intent#ACTION_SEND`. Note that to
match, the activity must support this action and a MIME type of "\*/\*".

<br />

Constant Value:

"android.app.action.REPORT_HEAP_LIMIT"


### LOCK_TASK_MODE_LOCKED

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

```
public static final int LOCK_TASK_MODE_LOCKED
```

Full lock task mode is active.

<br />

Constant Value:

1
(0x00000001)


### LOCK_TASK_MODE_NONE

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

```
public static final int LOCK_TASK_MODE_NONE
```

Lock task mode is not active.

<br />

Constant Value:

0
(0x00000000)


### LOCK_TASK_MODE_PINNED

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

```
public static final int LOCK_TASK_MODE_PINNED
```

App pinning mode is active.

<br />

Constant Value:

2
(0x00000002)


### META_HOME_ALTERNATE

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

```
public static final String META_HOME_ALTERNATE
```

[`<meta-data>`](https://developer.android.com/guide/topics/manifest/meta-data-element) name for a 'home' Activity that declares a package that is to be
uninstalled in lieu of the declaring one. The package named here must be
signed with the same certificate as the one declaring the `<meta-data>`.

<br />

Constant Value:

"android.app.home.alternate"


### MOVE_TASK_NO_USER_ACTION

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

```
public static final int MOVE_TASK_NO_USER_ACTION
```

Flag for `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int)`: don't count this as a
user-instigated action, so the current activity will not receive a
hint that the user is leaving.

<br />

Constant Value:

2
(0x00000002)


### MOVE_TASK_WITH_HOME

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

```
public static final int MOVE_TASK_WITH_HOME
```

Flag for `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int)`: also move the "home"
activity along with the task, so it is positioned immediately behind
the task. This flag is ignored if the task's windowing mode is
`https://developer.android.com/`.

<br />

Constant Value:

1
(0x00000001)


### RECENT_IGNORE_UNAVAILABLE

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

```
public static final int RECENT_IGNORE_UNAVAILABLE
```

Provides a list that does not contain any
recent tasks that currently are not available to the user.

<br />

Constant Value:

2
(0x00000002)


### RECENT_WITH_EXCLUDED

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

```
public static final int RECENT_WITH_EXCLUDED
```

Flag for use with `https://developer.android.com/reference/android/app/ActivityManager#getRecentTasks(int,%20int)`: return all tasks, even those
that have set their
`https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS` flag.

<br />

Constant Value:

1
(0x00000001)


## Public methods

### addAppTask

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

```
public int addAppTask (Activity activity, 
                Intent intent, 
                ActivityManager.TaskDescription description, 
                Bitmap thumbnail)
```

Add a new `https://developer.android.com/reference/android/app/ActivityManager.AppTask` for the calling application. This will create a new
recents entry that is added to the **end** of all existing recents.

<br />

| Parameters ||
|---|---|
| `activity` | `Activity`: The activity that is adding the entry. This is used to help determine the context that the new recents entry will be in. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The Intent that describes the recents entry. This is the same Intent that you would have used to launch the activity for it. In generally you will want to set both `https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_DOCUMENT` and `https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RETAIN_IN_RECENTS`; the latter is required since this recents entry will exist without an activity, so it doesn't make sense to not retain it when its activity disappears. The given Intent here also must have an explicit ComponentName set on it. This value cannot be `null`. <br /> |
| `description` | `ActivityManager.TaskDescription`: Optional additional description information. This value may be `null`. <br /> |
| `thumbnail` | `Bitmap`: Thumbnail to use for the recents entry. Should be the size given by `https://developer.android.com/reference/android/app/ActivityManager#getAppTaskThumbnailSize()`. If the bitmap is not that exact size, it will be recreated in your process, probably in a way you don't like, before the recents entry is added. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | Returns the task id of the newly added app task, or -1 if the add failed. The most likely cause of failure is that there is no more room for more tasks for your app. <br /> |

### addApplicationStartInfoCompletionListener

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

```
public void addApplicationStartInfoCompletionListener (Executor executor, 
                Consumer<ApplicationStartInfo> listener)
```

Adds a callback that is notified when the `https://developer.android.com/reference/android/app/ApplicationStartInfo` record of this startup
is complete. The startup is considered complete when the first frame is drawn.

The callback doesn't wait for `https://developer.android.com/reference/android/app/Activity#reportFullyDrawn()` to occur. Retrieve a copy
of `https://developer.android.com/reference/android/app/ApplicationStartInfo` after `https://developer.android.com/reference/android/app/Activity#reportFullyDrawn()` is called (using this
callback or `https://developer.android.com/`) if you need the
`https://developer.android.com/reference/android/app/ApplicationStartInfo#START_TIMESTAMP_FULLY_DRAWN` timestamp.

If the current start record has already been completed (that is, the process is not currently
starting), the callback will be invoked immediately on the specified executor with the
previously completed `https://developer.android.com/reference/android/app/ApplicationStartInfo` record.

Callback will be called at most once and removed automatically after being triggered.

Note: callback is asynchronous and should be made from a background thread.

<br />

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor on which the listener should be called. This value cannot be `null`. <br /> |
| `listener` | `Consumer`: Callback to be called when collection of `https://developer.android.com/reference/android/app/ApplicationStartInfo` is complete. Will replace existing listener if one is already attached. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if executor or listener are null. |

### addStartInfoTimestamp

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

```
public void addStartInfoTimestamp (int key, 
                long timestampNs)
```

Adds an optional developer supplied timestamp to the calling apps most recent
`https://developer.android.com/reference/android/app/ApplicationStartInfo`. This is in addition to system recorded timestamps.

Note: any timestamps added after `https://developer.android.com/reference/android/app/Activity#reportFullyDrawn()` is called
are discarded.

Note: will overwrite existing timestamp if called with same key.

<br />

<br />

| Parameters ||
|---|---|
| `key` | `int`: Unique key for timestamp. Must be greater than `https://developer.android.com/reference/android/app/ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_SYSTEM` and less than or equal to `https://developer.android.com/reference/android/app/ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_DEVELOPER`. Will thow `https://developer.android.com/reference/java/lang/IllegalArgumentException` if not in range. Value is between `https://developer.android.com/reference/android/app/ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START` and `https://developer.android.com/reference/android/app/ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_DEVELOPER` inclusive <br /> |
| `timestampNs` | `long`: Clock monotonic time in nanoseconds of event to be recorded. <br /> |

### appNotResponding

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

```
public void appNotResponding (String reason)
```

Method for the app to tell system that it's wedged and would like to trigger an ANR.

<br />

| Parameters ||
|---|---|
| `reason` | `String`: The description of that what happened. This value cannot be `null`. <br /> |

### clearApplicationUserData

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

```
public boolean clearApplicationUserData ()
```

Permits an application to erase its own data from disk. This is equivalent to
the user choosing to clear the app's data from within the device settings UI. It
erases all dynamic data associated with the app -- its private data and data in its
private area on external storage -- but does not remove the installed application
itself, nor any OBB files. It also revokes all runtime permissions that the app has acquired,
clears all notifications and removes all Uri grants related to this application.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the application successfully requested that the application's data be erased; `false` otherwise. <br /> |

### clearWatchHeapLimit

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

```
public void clearWatchHeapLimit ()
```

Clear a heap watch limit previously set by `https://developer.android.com/reference/android/app/ActivityManager#setWatchHeapLimit(long)`.

<br />

### dumpPackageState

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

```
public void dumpPackageState (FileDescriptor fd, 
                String packageName)
```

Perform a system dump of various state associated with the given application
package name. This call blocks while the dump is being performed, so should
not be done on a UI thread. The data will be written to the given file
descriptor as text.


Requires `https://developer.android.com/reference/android/Manifest.permission#DUMP`

<br />

| Parameters ||
|---|---|
| `fd` | `FileDescriptor`: The file descriptor that the dump should be written to. The file descriptor is *not* closed by this function; the caller continues to own it. <br /> |
| `packageName` | `String`: The name of the package that is to be dumped. <br /> |

### getAppTaskThumbnailSize

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

```
public Size getAppTaskThumbnailSize ()
```

Return the current design dimensions for `https://developer.android.com/reference/android/app/ActivityManager.AppTask` thumbnails, for use
with `https://developer.android.com/reference/android/app/ActivityManager#addAppTask(android.app.Activity,%20android.content.Intent,%20android.app.ActivityManager.TaskDescription,%20android.graphics.Bitmap)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/util/Size` | <br /> |

### getAppTasks

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

```
public List<ActivityManager.AppTask> getAppTasks ()
```

Get the list of tasks associated with the calling application.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.AppTask>` | The list of tasks associated with the application making this call. <br /> |

| Throws ||
|---|---|
|   | java.lang.SecurityException |

### getDeviceConfigurationInfo

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

```
public ConfigurationInfo getDeviceConfigurationInfo ()
```

Get the device configuration attributes.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/pm/ConfigurationInfo` | <br /> |

### getHistoricalProcessExitReasons

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

```
public List<ApplicationExitInfo> getHistoricalProcessExitReasons (String packageName, 
                int pid, 
                int maxNum)
```

Return a list of `https://developer.android.com/reference/android/app/ApplicationExitInfo` records containing the reasons for the most
recent app deaths.

Note: System stores this historical information in a ring buffer and only
the most recent records will be returned.

Note: In the case that this application was bound to an external service
with flag `https://developer.android.com/reference/android/content/Context#BIND_EXTERNAL_SERVICE`, the process of that external
service will be included in this package's exit info.

<br />

<br />

| Parameters ||
|---|---|
| `packageName` | `String`: Optional, a null value means match all packages belonging to the caller's UID. If this package belongs to another UID, you must hold `https://developer.android.com/reference/android/Manifest.permission#DUMP` in order to retrieve it. <br /> |
| `pid` | `int`: A process ID that used to belong to this package but died later; a value of 0 means to ignore this parameter and return all matching records. Value is 0 or greater <br /> |
| `maxNum` | `int`: The maximum number of results to be returned; a value of 0 means to ignore this parameter and return all matching records. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ApplicationExitInfo>` | a list of `https://developer.android.com/reference/android/app/ApplicationExitInfo` records matching the criteria, sorted in the order from most recent to least recent. This value cannot be `null`. <br /> |

### getHistoricalProcessStartReasons

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

```
public List<ApplicationStartInfo> getHistoricalProcessStartReasons (int maxNum)
```

Return a list of `https://developer.android.com/reference/android/app/ApplicationStartInfo` records containing the information about the
most recent app startups.

Records accessed using this path might include "incomplete" records such as in-progress app
starts. Accessing in-progress starts using this method lets you access start information
early to better optimize your startup path.

Note: System stores this historical information in a ring buffer and only
the most recent records will be returned.

<br />

<br />

| Parameters ||
|---|---|
| `maxNum` | `int`: The maximum number of results to be returned; a value of 0 means to ignore this parameter and return all matching records. If fewer records exist, all existing records will be returned. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ApplicationStartInfo>` | a list of `https://developer.android.com/reference/android/app/ApplicationStartInfo` records matching the criteria, sorted in the order from most recent to least recent. This value cannot be `null`. <br /> |

### getLargeMemoryClass

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

```
public int getLargeMemoryClass ()
```

Return the approximate per-application memory class of the current
device when an application is running with a large heap. This is the
space available for memory-intensive applications; most applications
should not need this amount of memory, and should instead stay with the
`https://developer.android.com/reference/android/app/ActivityManager#getMemoryClass()` limit. The returned value is in megabytes.
This may be the same size as `https://developer.android.com/reference/android/app/ActivityManager#getMemoryClass()` on memory
constrained devices, or it may be significantly larger on devices with
a large amount of available RAM.

This is the size of the application's Dalvik heap if it has
specified `android:largeHeap="true"` in its manifest.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getLauncherLargeIconDensity

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

```
public int getLauncherLargeIconDensity ()
```

Get the preferred density of icons for the launcher. This is used when
custom drawables are created (e.g., for shortcuts).

<br />

| Returns ||
|---|---|
| `int` | density in terms of DPI <br /> |

### getLauncherLargeIconSize

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

```
public int getLauncherLargeIconSize ()
```

Get the preferred launcher icon size. This is used when custom drawables
are created (e.g., for shortcuts).

<br />

| Returns ||
|---|---|
| `int` | dimensions of square icons in terms of pixels <br /> |

### getLockTaskModeState

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

```
public int getLockTaskModeState ()
```

Return the current state of task locking. The three possible outcomes
are `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_NONE`, `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_LOCKED`
and `https://developer.android.com/reference/android/app/ActivityManager#LOCK_TASK_MODE_PINNED`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

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

### getMemoryClass

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

```
public int getMemoryClass ()
```

Return the approximate per-application memory class of the current
device. This gives you an idea of how hard a memory limit you should
impose on your application to let the overall system work best. The
returned value is in megabytes; the baseline Android memory class is
16 (which happens to be the Java heap limit of those devices); some
devices with more memory may return 24 or even higher numbers.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getMemoryInfo

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

```
public void getMemoryInfo (ActivityManager.MemoryInfo outInfo)
```

Return general information about the memory state of the system. This
can be used to help decide how to manage your own memory, though note
that polling is not recommended and
`https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)` is the preferred way to do this.
Also see `https://developer.android.com/reference/android/app/ActivityManager#getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo)` for how to retrieve the current trim
level of your process as needed, which gives a better hint for how to
manage its memory.

<br />

| Parameters ||
|---|---|
| `outInfo` | `ActivityManager.MemoryInfo` <br /> |

### getMyMemoryState

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

```
public static void getMyMemoryState (ActivityManager.RunningAppProcessInfo outState)
```

Return global memory state information for the calling process. This
does not fill in all fields of the `https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo`. The
only fields that will be filled in are
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#pid`,
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#uid`,
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#lastTrimLevel`,
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#importance`,
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#lru`, and
`https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo#importanceReasonCode`.

<br />

| Parameters ||
|---|---|
| `outState` | `ActivityManager.RunningAppProcessInfo` <br /> |

### getProcessMemoryInfo

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

```
public MemoryInfo[] getProcessMemoryInfo (int[] pids)
```

Return information about the memory usage of one or more processes.

**Note: this method is only intended for debugging or building
a user-facing process management UI.**

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, for regular apps this method
will only return information about the memory info for the processes running as the
caller's uid; no other process memory info is available and will be zero.
Also of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` the sample rate allowed
by this API is significantly limited, if called faster the limit you will receive the
same data as the previous call.

<br />

<br />

| Parameters ||
|---|---|
| `pids` | `int`: The pids of the processes whose memory usage is to be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Debug.MemoryInfo` | Returns an array of memory information, one for each requested pid. <br /> |

### getProcessesInErrorState

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

```
public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState ()
```

Returns a list of any processes that are currently in an error condition. The result
will be null if all processes are running properly at this time.

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, for regular apps
this method will only return `https://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo` records for the processes running
as the caller's uid, unless the caller has the permission
`https://developer.android.com/reference/android/Manifest.permission#DUMP`.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo>` | Returns a list of `https://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo` records, or null if there are no current error conditions (it will not return an empty list). This list ordering is not specified. <br /> |

### getRecentTasks

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

```
public List<ActivityManager.RecentTaskInfo> getRecentTasks (int maxNum, 
                int flags)
```


**This method was deprecated
in API level 21.**   

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#LOLLIPOP`, this method is
no longer available to third party applications: the introduction of
document-centric recents means
it can leak personal information to the caller. For backwards compatibility,
it will still return a small subset of its data: at least the caller's
own tasks (though see `https://developer.android.com/reference/android/app/ActivityManager#getAppTasks()` for the correct supported
way to retrieve that information), and possibly some other tasks
such as home that are known to not be sensitive.

<br />

<br />

Return a list of the tasks that the user has recently launched, with the most recent being first and older ones after in order.

**Note: this method is only intended for debugging and presenting
task management user interfaces** . This should never be used for
core logic in an application, such as deciding between different
behaviors based on the information found here. Such uses are
*not* supported, and will likely break in the future. For
example, if multiple applications can be actively running at the
same time, assumptions made about the meaning of the data here for
purposes of control flow will be incorrect.

<br />

<br />

| Parameters ||
|---|---|
| `maxNum` | `int`: The maximum number of entries to return in the list. The actual number returned may be smaller, depending on how many tasks the user has started and the maximum number the system can remember. <br /> |
| `flags` | `int`: Information about what to return. May be any combination of `https://developer.android.com/reference/android/app/ActivityManager#RECENT_WITH_EXCLUDED` and `https://developer.android.com/reference/android/app/ActivityManager#RECENT_IGNORE_UNAVAILABLE`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo>` | Returns a list of RecentTaskInfo records describing each of the recent tasks. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` |   |

### getRunningAppProcesses

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

```
public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses ()
```

Returns a list of application processes that are running on the device.

**Note: this method is only intended for debugging or building
a user-facing process management UI.**

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo>` | Returns a list of RunningAppProcessInfo records, or null if there are no running processes (it will not return an empty list). This list ordering is not specified. <br /> |

### getRunningServiceControlPanel

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

```
public PendingIntent getRunningServiceControlPanel (ComponentName service)
```

Returns a PendingIntent you can start to show a control panel for the
given running service. If the service does not have a control panel,
null is returned.

<br />

| Parameters ||
|---|---|
| `service` | `ComponentName` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` |   |

### getRunningServices

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

```
public List<ActivityManager.RunningServiceInfo> getRunningServices (int maxNum)
```


**This method was deprecated
in API level 26.**   

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, this method
is no longer available to third party applications. For backwards compatibility,
it will still return the caller's own services.

Return a list of the services that are currently running.

**Note: this method is only intended for debugging or implementing
service management type user interfaces.**

<br />

<br />

| Parameters ||
|---|---|
| `maxNum` | `int`: The maximum number of entries to return in the list. The actual number returned may be smaller, depending on how many services are running. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo>` | Returns a list of RunningServiceInfo records describing each of the running tasks. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` |   |

### getRunningTasks

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

```
public List<ActivityManager.RunningTaskInfo> getRunningTasks (int maxNum)
```


**This method was deprecated
in API level 21.**   

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#LOLLIPOP`, this method
is no longer available to third party
applications: the introduction of document-centric recents means
it can leak person information to the caller. For backwards compatibility,
it will still return a small subset of its data: at least the caller's
own tasks, and possibly some other tasks
such as home that are known to not be sensitive.

Return a list of the tasks that are currently running, with
the most recent being first and older ones after in order. Note that
"running" does not mean any of the task's code is currently loaded or
activity -- the task may have been frozen by the system, so that it
can be restarted in its previous state when next brought to the
foreground.

**Note: this method is only intended for debugging and presenting
task management user interfaces** . This should never be used for
core logic in an application, such as deciding between different
behaviors based on the information found here. Such uses are
*not* supported, and will likely break in the future. For
example, if multiple applications can be actively running at the
same time, assumptions made about the meaning of the data here for
purposes of control flow will be incorrect.

<br />

<br />

| Parameters ||
|---|---|
| `maxNum` | `int`: The maximum number of entries to return in the list. The actual number returned may be smaller, depending on how many tasks the user has started. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo>` | Returns a list of RunningTaskInfo records describing each of the running tasks. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` |   |

### isActivityStartAllowedOnDisplay

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

```
public boolean isActivityStartAllowedOnDisplay (Context context, 
                int displayId, 
                Intent intent)
```

Check if the context is allowed to start an activity on specified display. Some launch
restrictions may apply to secondary displays that are private, virtual, or owned by the
system, in which case an activity start may throw a `https://developer.android.com/reference/java/lang/SecurityException`. Call this
method prior to starting an activity on a secondary display to check if the current context
has access to it.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Source context, from which an activity will be started. This value cannot be `null`. <br /> |
| `displayId` | `int`: Target display id. <br /> |
| `intent` | `Intent`: Intent used to launch an activity. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if a call to start an activity on the target display is allowed for the provided context and no `https://developer.android.com/reference/java/lang/SecurityException` will be thrown, `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/ActivityOptions#setLaunchDisplayId(int)`
- `https://developer.android.com/reference/android/view/Display#FLAG_PRIVATE`

### isBackgroundRestricted

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

```
public boolean isBackgroundRestricted ()
```

Query whether the user has enabled background restrictions for this app.

The user may chose to do this, if they see that an app is consuming an unreasonable
amount of battery while in the background.

If true, any work that the app tries to do will be aggressively restricted while it is in
the background. At a minimum, jobs and alarms will not execute and foreground services
cannot be started unless an app activity is in the foreground.

**Note that these restrictions stay in effect even when the device is charging.**

<br />

<br />

| Returns ||
|---|---|
| `boolean` | true if user has enforced background restrictions for this app, false otherwise. <br /> |

### isInLockTaskMode

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

```
public boolean isInLockTaskMode ()
```


**This method was deprecated
in API level 23.**   

Use `https://developer.android.com/reference/android/app/ActivityManager#getLockTaskModeState()` instead.

Return whether currently in lock task mode. When in this mode
no new tasks can be created or switched to.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

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

### isLowMemoryKillReportSupported

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

```
public static boolean isLowMemoryKillReportSupported ()
```

<br />

<br />

| Returns ||
|---|---|
| `boolean` | Whether or not the low memory kill will be reported in `https://developer.android.com/reference/android/app/ActivityManager#getHistoricalProcessExitReasons(java.lang.String,%20int,%20int)`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/ApplicationExitInfo#REASON_LOW_MEMORY`

### isLowRamDevice

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

```
public boolean isLowRamDevice ()
```

Returns true if this is a low-RAM device. Exactly whether a device is low-RAM
is ultimately up to the device configuration, but currently it generally means
something with 1GB or less of RAM. This is mostly intended to be used by apps
to determine whether they should turn off certain features that require more RAM.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isRunningInTestHarness

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

```
public static boolean isRunningInTestHarness ()
```


**This method was deprecated
in API level 29.**   

this method is false for all user builds. Users looking to check if their device
is running in a device farm should see `https://developer.android.com/reference/android/app/ActivityManager#isRunningInUserTestHarness()`.

Returns "true" if device is running in a test harness.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isRunningInUserTestHarness

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

```
public static boolean isRunningInUserTestHarness ()
```

Returns "true" if the device is running in Test Harness Mode.

Test Harness Mode is a feature that allows devices to run without human interaction in a
device farm/testing harness (such as Firebase Test Lab). You should check this method if you
want your app to behave differently when running in a test harness to skip setup screens that
would impede UI testing. e.g. a keyboard application that has a full screen setup page for
the first time it is launched.

Note that you should *not* use this to determine whether or not your app is running
an instrumentation test, as it is not set for a standard device running a test.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isUserAMonkey

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

```
public static boolean isUserAMonkey ()
```

Returns "true" if the user interface is currently being messed with by a
[monkey](https://developer.android.com/studio/test/other-testing-tools/monkey).

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### killBackgroundProcesses

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

```
public void killBackgroundProcesses (String packageName)
```

Have the system immediately kill all background processes associated
with the given package. This is the same as the kernel killing those
processes to reclaim memory; the system will take care of restarting
these processes in the future as needed.

On devices that run Android 14 or higher,
third party applications can only use this API to kill their own processes.
.   
Requires `https://developer.android.com/reference/android/Manifest.permission#KILL_BACKGROUND_PROCESSES`

<br />

<br />

| Parameters ||
|---|---|
| `packageName` | `String`: The name of the package whose processes are to be killed. <br /> |

### moveTaskToFront

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

```
public void moveTaskToFront (int taskId, 
                int flags, 
                Bundle options)
```

Ask that the task associated with a given task ID be moved to the
front of the stack, so it is now visible to the user.


Requires `https://developer.android.com/reference/android/Manifest.permission#REORDER_TASKS`

<br />

| Parameters ||
|---|---|
| `taskId` | `int`: The identifier of the task to be moved, as found in `https://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo` or `https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo`. <br /> |
| `flags` | `int`: Additional operational flags. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_WITH_HOME` - `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_NO_USER_ACTION` |
| `options` | `Bundle`: Additional options for the operation, either null or as per `https://developer.android.com/reference/android/content/Context#startActivity(android.content.Intent,%20android.os.Bundle)`. <br /> |

### moveTaskToFront

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

```
public void moveTaskToFront (int taskId, 
                int flags)
```

Equivalent to calling `https://developer.android.com/reference/android/app/ActivityManager#moveTaskToFront(int,%20int,%20android.os.Bundle)`
with a null options argument.


Requires `https://developer.android.com/reference/android/Manifest.permission#REORDER_TASKS`

<br />

| Parameters ||
|---|---|
| `taskId` | `int`: The identifier of the task to be moved, as found in `https://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo` or `https://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo`. <br /> |
| `flags` | `int`: Additional operational flags. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_WITH_HOME` - `https://developer.android.com/reference/android/app/ActivityManager#MOVE_TASK_NO_USER_ACTION` |

### registerAnrWarningListener

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

```
public void registerAnrWarningListener (Executor executor, 
                Consumer<AnrWarningResult> listener)
```

Registers a listener that is called when the app is close to the ANR timeout.

This is intended to give the app a chance to collect and store any additional information
they may want to gather at this time, or take any pre-ANR actions. Note that these listeners
are called at best-effort, and may not be successfully called (or be provided time to
execute) before the ANR occurs and the app is killed.

If the app registers multiple distinct listeners, all registered listeners will be
notified on the potential ANR condition. The order in which listeners are notified is not
guaranteed.

The app can unregister the listener using `https://developer.android.com/reference/android/app/ActivityManager#unregisterAnrWarningListener(java.util.function.Consumer<android.app.AnrWarningResult>)`.

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor on which listener will be invoked. This should not be the application's main thread. This value cannot be `null`. <br /> |
| `listener` | `Consumer`: The listener to be triggered on the ANR warning condition. This value cannot be `null`. <br /> |

### removeApplicationStartInfoCompletionListener

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

```
public void removeApplicationStartInfoCompletionListener (Consumer<ApplicationStartInfo> listener)
```

Removes the provided callback set by `https://developer.android.com/reference/android/app/ActivityManager#addApplicationStartInfoCompletionListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.ApplicationStartInfo>)`.

<br />

| Parameters ||
|---|---|
| `listener` | `Consumer`: This value cannot be `null`. <br /> |

### restartPackage

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

```
public void restartPackage (String packageName)
```


**This method was deprecated
in API level 15.**   

This is now just a wrapper for
`https://developer.android.com/reference/android/app/ActivityManager#killBackgroundProcesses(java.lang.String)`; the previous behavior here
is no longer available to applications because it allows them to
break other applications by removing their alarms, stopping their
services, etc.

<br />

<br />

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

### setProcessStateSummary

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

```
public void setProcessStateSummary (byte[] state)
```

Set custom state data for this process. It will be included in the record of
`https://developer.android.com/reference/android/app/ApplicationExitInfo` on the death of the current calling process; the new process
of the app can retrieve this state data by calling
`https://developer.android.com/reference/android/app/ApplicationExitInfo#getProcessStateSummary()` on the record returned by
`https://developer.android.com/reference/android/app/ActivityManager#getHistoricalProcessExitReasons(java.lang.String,%20int,%20int)`.

This would be useful for the calling app to save its stateful data: if it's
killed later for any reason, the new process of the app can know what the
previous process of the app was doing. For instance, you could use this to encode
the current level in a game, or a set of features/experiments that were enabled. Later you
could analyze under what circumstances the app tends to crash or use too much memory.
However, it's not suggested to rely on this to restore the applications previous UI state
or so, it's only meant for analyzing application healthy status.

System might decide to throttle the calls to this API; so call this API in a reasonable
manner, excessive calls to this API could result a `https://developer.android.com/reference/java/lang/RuntimeException`.

<br />

<br />

| Parameters ||
|---|---|
| `state` | `byte`: The state data. To be advised, **DO NOT** include sensitive information/data (PII, SPII, or other sensitive user data) here. Maximum length is 128 bytes. This value may be `null`. <br /> |

### setVrThread

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

```
public static void setVrThread (int tid)
```

Enable more aggressive scheduling for latency-sensitive low-runtime VR threads. Only one
thread can be a VR thread in a process at a time, and that thread may be subject to
restrictions on the amount of time it can run.

If persistent VR mode is set, whatever thread has been granted aggressive scheduling via this
method will return to normal operation, and calling this method will do nothing while
persistent VR mode is enabled.

To reset the VR thread for an application, a tid of 0 can be passed.

<br />

| Parameters ||
|---|---|
| `tid` | `int`: tid of the VR thread <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/Process#myTid()`

### setWatchHeapLimit

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

```
public void setWatchHeapLimit (long pssSize)
```

Request that the system start watching for the calling process to exceed a pss
size as given here. Once called, the system will look for any occasions where it
sees the associated process with a larger pss size and, when this happens, automatically
pull a heap dump from it and allow the user to share the data. Note that this request
continues running even if the process is killed and restarted. To remove the watch,
use `https://developer.android.com/reference/android/app/ActivityManager#clearWatchHeapLimit()`.

This API only works if the calling process has been marked as
`https://developer.android.com/reference/android/content/pm/ApplicationInfo#FLAG_DEBUGGABLE` or this is running on a debuggable
(userdebug or eng) build.

Callers can optionally implement `https://developer.android.com/reference/android/app/ActivityManager#ACTION_REPORT_HEAP_LIMIT` to directly
handle heap limit reports themselves.

<br />

<br />

| Parameters ||
|---|---|
| `pssSize` | `long`: The size in bytes to set the limit at. <br /> |

### unregisterAnrWarningListener

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

```
public void unregisterAnrWarningListener (Consumer<AnrWarningResult> listener)
```

Unregisters a previously registered ANR warning listener.

<br />

| Parameters ||
|---|---|
| `listener` | `Consumer`: The listener to unregister. This must be the same object that was previously passed to `https://developer.android.com/reference/android/app/ActivityManager#registerAnrWarningListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.AnrWarningResult>)`. This value cannot be `null`. <br /> |