{
	"id": "cad011db-15d4-4242-a352-f423d0187c3a",
	"created_at": "2026-04-06T00:17:55.613005Z",
	"updated_at": "2026-04-10T13:12:21.970657Z",
	"deleted_at": null,
	"sha1_hash": "d760656e23d7e3e5579ffc89252c2c83539e9a85",
	"title": "ActivityManager  |  API reference  |  Android Developers",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 360379,
	"plain_text": "ActivityManager  |  API reference  |  Android Developers\r\nArchived: 2026-04-02 10:41:17 UTC\r\nActivityManager Stay organized with collections Save and categorize content\r\nbased on your preferences.\r\npublic class ActivityManager\r\nextends Object\r\nThis class gives information about, and interacts with, activities, services, and the containing process.\r\nA number of the methods in this class are for debugging or informational purposes and they should not be used to\r\naffect any runtime behavior of your app. These methods are called out as such in the method level documentation.\r\nMost application developers should not have the need to use this class, most of whose methods are for specialized\r\nuse cases. However, a few methods are more broadly applicable. For instance, isLowRamDevice() enables your\r\napp to detect whether it is running on a low-memory device, and behave accordingly.\r\nclearApplicationUserData() is for apps with reset-data functionality.\r\nIn some special use cases, where an app interacts with its Task stack, the app may use the\r\nActivityManager.AppTask and ActivityManager.RecentTaskInfo inner classes. However, in general, the\r\nmethods in this class should be used for testing and debugging purposes only.\r\nSummary\r\nPublic methods\r\nint\r\naddAppTask(Activity activity, Intent intent, ActivityManager.Task\r\nDescription description, Bitmap thumbnail)\r\nAdd a new AppTask for the calling application.\r\nvoid\r\naddApplicationStartInfoCompletionListener(Executor executor,\r\nConsumer\u003cApplicationStartInfo\u003e listener)\r\nAdds a callback that is notified when the ApplicationStartInfo record of this\r\nstartup is complete.\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 1 of 22\n\nvoid\r\naddStartInfoTimestamp(int key, long timestampNs)\r\nAdds an optional developer supplied timestamp to the calling apps most recent\r\nApplicationStartInfo .\r\nvoid\r\nappNotResponding(String reason)\r\nMethod for the app to tell system that it's wedged and would like to trigger an ANR.\r\nboolean\r\nclearApplicationUserData()\r\nPermits an application to erase its own data from disk.\r\nvoid\r\nclearWatchHeapLimit()\r\nClear a heap watch limit previously set by setWatchHeapLimit(long) .\r\nvoid\r\ndumpPackageState(FileDescriptor fd, String packageName)\r\nPerform a system dump of various state associated with the given application package\r\nname.\r\nSize\r\ngetAppTaskThumbnailSize()\r\nReturn the current design dimensions for AppTask thumbnails, for use with\r\naddAppTask(Activity, Intent, TaskDescription, Bitmap) .\r\nList\u003cActivity\r\nManager.AppTask\u003e\r\ngetAppTasks()\r\nGet the list of tasks associated with the calling application.\r\nConfiguration\r\nInfo\r\ngetDeviceConfigurationInfo()\r\nGet the device configuration attributes.\r\nList\u003cApplication\r\nExitInfo\u003e\r\ngetHistoricalProcessExitReasons(String packageName, int pid, int maxNum)\r\nReturn a list of ApplicationExitInfo records containing the reasons for the most\r\nrecent app deaths.\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 2 of 22\n\nList\u003cApplication\r\nStartInfo\u003e\r\ngetHistoricalProcessStartReasons(int maxNum)\r\nReturn a list of ApplicationStartInfo records containing the information about the\r\nmost recent app startups.\r\nint\r\ngetLargeMemoryClass()\r\nReturn the approximate per-application memory class of the current device when an\r\napplication is running with a large heap.\r\nint\r\ngetLauncherLargeIconDensity()\r\nGet the preferred density of icons for the launcher.\r\nint\r\ngetLauncherLargeIconSize()\r\nGet the preferred launcher icon size.\r\nint\r\ngetLockTaskModeState()\r\nReturn the current state of task locking.\r\nint\r\ngetMemoryClass()\r\nReturn the approximate per-application memory class of the current device.\r\nvoid\r\ngetMemoryInfo(ActivityManager.MemoryInfo outInfo)\r\nReturn general information about the memory state of the system.\r\nstatic void\r\ngetMyMemoryState(ActivityManager.RunningAppProcessInfo outState)\r\nReturn global memory state information for the calling process.\r\nMemoryInfo[]\r\ngetProcessMemoryInfo(int[] pids)\r\nReturn information about the memory usage of one or more processes.\r\nList\u003cActivity\r\nManager.Process\r\nErrorStateInfo\u003e\r\ngetProcessesInErrorState()\r\nReturns a list of any processes that are currently in an error condition.\r\nList\u003cActivity\r\nManager.RecentTask\r\ngetRecentTasks(int maxNum, int flags)\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 3 of 22\n\nInfo\u003e This method was deprecated in API level 21. As of Build.VERSION_CODES.LOLLIPOP ,\r\nthis method is no longer available to third party applications: the introduction of\r\ndocument-centric recents means it can leak personal information to the caller. For\r\nbackwards compatibility, it will still return a small subset of its data: at least the\r\ncaller's own tasks (though see getAppTasks() for the correct supported way to\r\nretrieve that information), and possibly some other tasks such as home that are\r\nknown to not be sensitive.\r\nList\u003cActivity\r\nManager.RunningApp\r\nProcessInfo\u003e\r\ngetRunningAppProcesses()\r\nReturns a list of application processes that are running on the device.\r\nPendingIntent\r\ngetRunningServiceControlPanel(ComponentName service)\r\nReturns a PendingIntent you can start to show a control panel for the given running\r\nservice.\r\nList\u003cActivity\r\nManager.Running\r\nServiceInfo\u003e\r\ngetRunningServices(int maxNum)\r\nThis method was deprecated in API level 26. As of Build.VERSION_CODES.O , this\r\nmethod is no longer available to third party applications. For backwards\r\ncompatibility, it will still return the caller's own services.\r\nList\u003cActivity\r\nManager.Running\r\nTaskInfo\u003e\r\ngetRunningTasks(int maxNum)\r\nThis method was deprecated in API level 21. As of Build.VERSION_CODES.LOLLIPOP ,\r\nthis method is no longer available to third party applications: the introduction of\r\ndocument-centric recents means it can leak person information to the caller. For\r\nbackwards compatibility, it will still return a small subset of its data: at least the\r\ncaller's own tasks, and possibly some other tasks such as home that are known to not\r\nbe sensitive.\r\nboolean\r\nisActivityStartAllowedOnDisplay(Context context, int displayId, Intent\r\nintent)\r\nCheck if the context is allowed to start an activity on specified display.\r\nboolean\r\nisBackgroundRestricted()\r\nQuery whether the user has enabled background restrictions for this app.\r\nboolean isInLockTaskMode()\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 4 of 22\n\nThis method was deprecated in API level 23. Use getLockTaskModeState() instead.\r\nstatic boolean isLowMemoryKillReportSupported()\r\nboolean\r\nisLowRamDevice()\r\nReturns true if this is a low-RAM device.\r\nstatic boolean\r\nisRunningInTestHarness()\r\nThis method was deprecated in API level 29. this method is false for all user builds.\r\nUsers looking to check if their device is running in a device farm should see\r\nisRunningInUserTestHarness() .\r\nstatic boolean\r\nisRunningInUserTestHarness()\r\nReturns \"true\" if the device is running in Test Harness Mode.\r\nstatic boolean\r\nisUserAMonkey()\r\nReturns \"true\" if the user interface is currently being messed with by a monkey.\r\nvoid\r\nkillBackgroundProcesses(String packageName)\r\nHave the system immediately kill all background processes associated with the given\r\npackage.\r\nvoid\r\nmoveTaskToFront(int taskId, int flags, Bundle options)\r\nAsk that the task associated with a given task ID be moved to the front of the stack,\r\nso it is now visible to the user.\r\nvoid\r\nmoveTaskToFront(int taskId, int flags)\r\nEquivalent to calling moveTaskToFront(int,int,Bundle) with a null options\r\nargument.\r\nvoid\r\nregisterAnrWarningListener(Executor executor, Consumer\u003cAnrWarningResult\u003e\r\nlistener)\r\nRegisters a listener that is called when the app is close to the ANR timeout.\r\nvoid removeApplicationStartInfoCompletionListener(Consumer\u003cApplicationStartInfo\u003e\r\nlistener)\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 5 of 22\n\nRemoves the provided callback set by\r\naddApplicationStartInfoCompletionListener(Executor, Consumer) .\r\nvoid\r\nrestartPackage(String packageName)\r\nThis method was deprecated in API level 15. This is now just a wrapper for\r\nkillBackgroundProcesses(String) ; the previous behavior here is no longer\r\navailable to applications because it allows them to break other applications by\r\nremoving their alarms, stopping their services, etc.\r\nvoid\r\nsetProcessStateSummary(byte[] state)\r\nSet custom state data for this process.\r\nstatic void\r\nsetVrThread(int tid)\r\nEnable more aggressive scheduling for latency-sensitive low-runtime VR threads.\r\nvoid\r\nsetWatchHeapLimit(long pssSize)\r\nRequest that the system start watching for the calling process to exceed a pss size as\r\ngiven here.\r\nvoid\r\nunregisterAnrWarningListener(Consumer\u003cAnrWarningResult\u003e listener)\r\nUnregisters a previously registered ANR warning listener.\r\nInherited methods\r\nFrom class java.lang.Object\r\nObject\r\nclone()\r\nCreates and returns a copy of this object.\r\nboolean\r\nequals(Object obj)\r\nIndicates whether some other object is \"equal to\" this one.\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 6 of 22\n\nvoid\r\nfinalize()\r\nCalled by the garbage collector on an object when garbage collection determines that\r\nthere are no more references to the object.\r\nfinal\r\nClass\u003c?\u003e\r\ngetClass()\r\nReturns the runtime class of this Object .\r\nint\r\nhashCode()\r\nReturns a hash code value for the object.\r\nfinal void\r\nnotify()\r\nWakes up a single thread that is waiting on this object's monitor.\r\nfinal void\r\nnotifyAll()\r\nWakes up all threads that are waiting on this object's monitor.\r\nString\r\ntoString()\r\nReturns a string representation of the object.\r\nfinal void\r\nwait(long timeoutMillis, int nanos)\r\nCauses the current thread to wait until it is awakened, typically by being notified or\r\ninterrupted, or until a certain amount of real time has elapsed.\r\nfinal void\r\nwait(long timeoutMillis)\r\nCauses the current thread to wait until it is awakened, typically by being notified or\r\ninterrupted, or until a certain amount of real time has elapsed.\r\nfinal void\r\nwait()\r\nCauses the current thread to wait until it is awakened, typically by being notified or\r\ninterrupted.\r\nConstants\r\nACTION_REPORT_HEAP_LIMIT\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 7 of 22\n\npublic static final String ACTION_REPORT_HEAP_LIMIT\r\nAction an app can implement to handle reports from setWatchHeapLimit(long) . If your package has an activity\r\nhandling this action, it will be launched with the heap data provided to it the same way as Intent.ACTION_SEND .\r\nNote that to match, the activity must support this action and a MIME type of \"*/*\".\r\nConstant Value: \"android.app.action.REPORT_HEAP_LIMIT\"\r\nLOCK_TASK_MODE_LOCKED\r\npublic static final int LOCK_TASK_MODE_LOCKED\r\nFull lock task mode is active.\r\nConstant Value: 1 (0x00000001)\r\nLOCK_TASK_MODE_NONE\r\npublic static final int LOCK_TASK_MODE_NONE\r\nLock task mode is not active.\r\nConstant Value: 0 (0x00000000)\r\nLOCK_TASK_MODE_PINNED\r\npublic static final int LOCK_TASK_MODE_PINNED\r\nApp pinning mode is active.\r\nConstant Value: 2 (0x00000002)\r\nMETA_HOME_ALTERNATE\r\npublic static final String META_HOME_ALTERNATE\r\n\u003cmeta-data\u003e name for a 'home' Activity that declares a package that is to be uninstalled in lieu of the declaring\r\none. The package named here must be signed with the same certificate as the one declaring the \u003cmeta-data\u003e .\r\nConstant Value: \"android.app.home.alternate\"\r\nMOVE_TASK_NO_USER_ACTION\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 8 of 22\n\npublic static final int MOVE_TASK_NO_USER_ACTION\r\nFlag for moveTaskToFront(int, int) : don't count this as a user-instigated action, so the current activity will not\r\nreceive a hint that the user is leaving.\r\nConstant Value: 2 (0x00000002)\r\nRECENT_IGNORE_UNAVAILABLE\r\npublic static final int RECENT_IGNORE_UNAVAILABLE\r\nProvides a list that does not contain any recent tasks that currently are not available to the user.\r\nConstant Value: 2 (0x00000002)\r\nPublic methods\r\naddAppTask\r\npublic int addAppTask (Activity activity,\r\n Intent intent,\r\n ActivityManager.TaskDescription description,\r\n Bitmap thumbnail)\r\nAdd a new AppTask for the calling application. This will create a new recents entry that is added to the end of all\r\nexisting recents.\r\nParameters\r\nactivity\r\nActivity : The activity that is adding the entry. This is used to help determine the context\r\nthat the new recents entry will be in.\r\nThis value cannot be null .\r\nintent\r\nIntent : The Intent that describes the recents entry. This is the same Intent that you would\r\nhave used to launch the activity for it. In generally you will want to set both Intent.FLAG_\r\nACTIVITY_NEW_DOCUMENT and Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS ; the latter is\r\nrequired since this recents entry will exist without an activity, so it doesn't make sense to not\r\nretain it when its activity disappears. The given Intent here also must have an explicit\r\nComponentName set on it.\r\nThis value cannot be null .\r\ndescription\r\nActivityManager.TaskDescription : Optional additional description information.\r\nThis value may be null .\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 9 of 22\n\nthumbnail\r\nBitmap : Thumbnail to use for the recents entry. Should be the size given by getAppTask\r\nThumbnailSize() . If the bitmap is not that exact size, it will be recreated in your process,\r\nprobably in a way you don't like, before the recents entry is added.\r\nThis value cannot be null .\r\nReturns\r\nint\r\nReturns the task id of the newly added app task, or -1 if the add failed. The most likely cause of\r\nfailure is that there is no more room for more tasks for your app.\r\naddApplicationStartInfoCompletionListener\r\npublic void addApplicationStartInfoCompletionListener (Executor executor,\r\n Consumer\u003cApplicationStartInfo\u003e listener)\r\nAdds a callback that is notified when the ApplicationStartInfo record of this startup is complete. The startup is\r\nconsidered complete when the first frame is drawn. The callback doesn't wait for Activity.reportFullyDrawn to\r\noccur. Retrieve a copy of ApplicationStartInfo after Activity.reportFullyDrawn is called (using this\r\ncallback or ERROR(/getHistoricalProcessStartReasons) ) if you need the\r\nApplicationStartInfo.START_TIMESTAMP_FULLY_DRAWN timestamp. If the current start record has already been\r\ncompleted (that is, the process is not currently starting), the callback will be invoked immediately on the specified\r\nexecutor with the previously completed ApplicationStartInfo record. Callback will be called at most once and\r\nremoved automatically after being triggered.\r\nNote: callback is asynchronous and should be made from a background thread.\r\nParameters\r\nexecutor\r\nExecutor : The executor on which the listener should be called.\r\nThis value cannot be null .\r\nlistener\r\nConsumer : Callback to be called when collection of ApplicationStartInfo is complete. Will\r\nreplace existing listener if one is already attached.\r\nThis value cannot be null .\r\naddStartInfoTimestamp\r\npublic void addStartInfoTimestamp (int key,\r\n long timestampNs)\r\nAdds an optional developer supplied timestamp to the calling apps most recent ApplicationStartInfo . This is in\r\naddition to system recorded timestamps.\r\nNote: any timestamps added after Activity.reportFullyDrawn is called are discarded.\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 10 of 22\n\nNote: will overwrite existing timestamp if called with same key.\r\nappNotResponding\r\npublic void appNotResponding (String reason)\r\nMethod for the app to tell system that it's wedged and would like to trigger an ANR.\r\nParameters\r\nreason\r\nString : The description of that what happened.\r\nThis value cannot be null .\r\nclearApplicationUserData\r\npublic boolean clearApplicationUserData ()\r\nPermits an application to erase its own data from disk. This is equivalent to the user choosing to clear the app's\r\ndata from within the device settings UI. It erases all dynamic data associated with the app -- its private data and\r\ndata in its private area on external storage -- but does not remove the installed application itself, nor any OBB\r\nfiles. It also revokes all runtime permissions that the app has acquired, clears all notifications and removes all Uri\r\ngrants related to this application.\r\nReturns\r\nboolean\r\ntrue if the application successfully requested that the application's data be erased; false\r\notherwise.\r\nclearWatchHeapLimit\r\npublic void clearWatchHeapLimit ()\r\nClear a heap watch limit previously set by setWatchHeapLimit(long) .\r\ndumpPackageState\r\npublic void dumpPackageState (FileDescriptor fd,\r\n String packageName)\r\nPerform a system dump of various state associated with the given application package name. This call blocks\r\nwhile the dump is being performed, so should not be done on a UI thread. The data will be written to the given file\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 11 of 22\n\ndescriptor as text.\r\nRequires Manifest.permission.DUMP\r\nParameters\r\nfd\r\nFileDescriptor : The file descriptor that the dump should be written to. The file descriptor is\r\nnot closed by this function; the caller continues to own it.\r\npackage\r\nName\r\nString : The name of the package that is to be dumped.\r\ngetAppTasks\r\npublic List\u003cActivityManager.AppTask\u003e getAppTasks ()\r\nGet the list of tasks associated with the calling application.\r\nThrows\r\njava.lang.SecurityException\r\ngetDeviceConfigurationInfo\r\npublic ConfigurationInfo getDeviceConfigurationInfo ()\r\nGet the device configuration attributes.\r\ngetHistoricalProcessExitReasons\r\npublic List\u003cApplicationExitInfo\u003e getHistoricalProcessExitReasons (String packageName,\r\n int pid,\r\n int maxNum)\r\nReturn a list of ApplicationExitInfo records containing the reasons for the most recent app deaths.\r\nNote: System stores this historical information in a ring buffer and only the most recent records will be returned.\r\nNote: In the case that this application was bound to an external service with flag\r\nContext.BIND_EXTERNAL_SERVICE , the process of that external service will be included in this package's exit info.\r\nParameters\r\npackage\r\nName\r\nString : Optional, a null value means match all packages belonging to the caller's UID. If this\r\npackage belongs to another UID, you must hold Manifest.permission.DUMP in order to\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 12 of 22\n\nretrieve it.\r\npid\r\nint : A process ID that used to belong to this package but died later; a value of 0 means to\r\nignore this parameter and return all matching records.\r\nValue is 0 or greater\r\nmaxNum\r\nint : The maximum number of results to be returned; a value of 0 means to ignore this\r\nparameter and return all matching records.\r\nValue is 0 or greater\r\ngetHistoricalProcessStartReasons\r\npublic List\u003cApplicationStartInfo\u003e getHistoricalProcessStartReasons (int maxNum)\r\nReturn a list of ApplicationStartInfo records containing the information about the most recent app startups.\r\nRecords 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.\r\nNote: System stores this historical information in a ring buffer and only the most recent records will be returned.\r\nParameters\r\nmax\r\nNum\r\nint : The maximum number of results to be returned; a value of 0 means to ignore this parameter\r\nand return all matching records. If fewer records exist, all existing records will be returned.\r\nValue is 0 or greater\r\ngetLargeMemoryClass\r\npublic int getLargeMemoryClass ()\r\nReturn the approximate per-application memory class of the current device when an application is running with a\r\nlarge heap. This is the space available for memory-intensive applications; most applications should not need this\r\namount of memory, and should instead stay with the getMemoryClass() limit. The returned value is in\r\nmegabytes. This may be the same size as getMemoryClass() on memory constrained devices, or it may be\r\nsignificantly larger on devices with a large amount of available RAM.\r\nThis is the size of the application's Dalvik heap if it has specified android:largeHeap=\"true\" in its manifest.\r\ngetLauncherLargeIconDensity\r\npublic int getLauncherLargeIconDensity ()\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 13 of 22\n\nGet the preferred density of icons for the launcher. This is used when custom drawables are created (e.g., for\r\nshortcuts).\r\nReturns\r\nint density in terms of DPI\r\ngetLauncherLargeIconSize\r\npublic int getLauncherLargeIconSize ()\r\nGet the preferred launcher icon size. This is used when custom drawables are created (e.g., for shortcuts).\r\nReturns\r\nint dimensions of square icons in terms of pixels\r\ngetMemoryClass\r\npublic int getMemoryClass ()\r\nReturn the approximate per-application memory class of the current device. This gives you an idea of how hard a\r\nmemory limit you should impose on your application to let the overall system work best. The returned value is in\r\nmegabytes; the baseline Android memory class is 16 (which happens to be the Java heap limit of those devices);\r\nsome devices with more memory may return 24 or even higher numbers.\r\ngetMemoryInfo\r\npublic void getMemoryInfo (ActivityManager.MemoryInfo outInfo)\r\nReturn general information about the memory state of the system. This can be used to help decide how to manage\r\nyour own memory, though note that polling is not recommended and ComponentCallbacks2.onTrimMemory(int)\r\nis the preferred way to do this. Also see getMyMemoryState(RunningAppProcessInfo) for how to retrieve the\r\ncurrent trim level of your process as needed, which gives a better hint for how to manage its memory.\r\nParameters\r\noutInfo ActivityManager.MemoryInfo\r\ngetProcessMemoryInfo\r\npublic MemoryInfo[] getProcessMemoryInfo (int[] pids)\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 14 of 22\n\nReturn information about the memory usage of one or more processes.\r\nNote: this method is only intended for debugging or building a user-facing process management UI.\r\nAs of Android Q , for regular apps this method will only return information about the memory info for the\r\nprocesses running as the caller's uid; no other process memory info is available and will be zero. Also of Android\r\nQ the sample rate allowed by this API is significantly limited, if called faster the limit you will receive the same\r\ndata as the previous call.\r\nParameters\r\npids int : The pids of the processes whose memory usage is to be retrieved.\r\nReturns\r\nMemoryInfo[] Returns an array of memory information, one for each requested pid.\r\ngetRecentTasks\r\npublic List\u003cActivityManager.RecentTaskInfo\u003e getRecentTasks (int maxNum,\r\n int flags)\r\nThis method was deprecated in API level 21.\r\nAs of Build.VERSION_CODES.LOLLIPOP , this method is no longer available to third party applications: the\r\nintroduction of document-centric recents means it can leak personal information to the caller. For backwards\r\ncompatibility, it will still return a small subset of its data: at least the caller's own tasks (though see\r\ngetAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as\r\nhome that are known to not be sensitive.\r\nReturn a list of the tasks that the user has recently launched, with the most recent being first and older ones after in\r\norder.\r\nNote: this method is only intended for debugging and presenting task management user interfaces. This\r\nshould never be used for core logic in an application, such as deciding between different behaviors based on the\r\ninformation found here. Such uses are not supported, and will likely break in the future. For example, if multiple\r\napplications can be actively running at the same time, assumptions made about the meaning of the data here for\r\npurposes of control flow will be incorrect.\r\nParameters\r\nmax\r\nNum\r\nint : The maximum number of entries to return in the list. The actual number returned may be\r\nsmaller, depending on how many tasks the user has started and the maximum number the system\r\ncan remember.\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 15 of 22\n\nflags\r\nint : Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and\r\nRECENT_IGNORE_UNAVAILABLE .\r\ngetRunningAppProcesses\r\npublic List\u003cActivityManager.RunningAppProcessInfo\u003e getRunningAppProcesses ()\r\nReturns a list of application processes that are running on the device.\r\nNote: this method is only intended for debugging or building a user-facing process management UI.\r\nReturns\r\nList\u003cActivityManager.\r\nRunningAppProcessInfo\u003e\r\nReturns a list of RunningAppProcessInfo records, or null if there are no\r\nrunning processes (it will not return an empty list). This list ordering is not\r\nspecified.\r\ngetRunningServiceControlPanel\r\npublic PendingIntent getRunningServiceControlPanel (ComponentName service)\r\nReturns a PendingIntent you can start to show a control panel for the given running service. If the service does not\r\nhave a control panel, null is returned.\r\nParameters\r\nservice ComponentName\r\ngetRunningServices\r\npublic List\u003cActivityManager.RunningServiceInfo\u003e getRunningServices (int maxNum)\r\nThis method was deprecated in API level 26.\r\nAs of Build.VERSION_CODES.O , this method is no longer available to third party applications. For backwards\r\ncompatibility, it will still return the caller's own services.\r\nReturn a list of the services that are currently running.\r\nNote: this method is only intended for debugging or implementing service management type user interfaces.\r\nParameters\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 16 of 22\n\nmax\r\nNum\r\nint : The maximum number of entries to return in the list. The actual number returned may be\r\nsmaller, depending on how many services are running.\r\ngetRunningTasks\r\npublic List\u003cActivityManager.RunningTaskInfo\u003e getRunningTasks (int maxNum)\r\nThis method was deprecated in API level 21.\r\nAs of Build.VERSION_CODES.LOLLIPOP , this method is no longer available to third party applications: the\r\nintroduction of document-centric recents means it can leak person information to the caller. For backwards\r\ncompatibility, it will still return a small subset of its data: at least the caller's own tasks, and possibly some other\r\ntasks such as home that are known to not be sensitive.\r\nReturn a list of the tasks that are currently running, with the most recent being first and older ones after in order.\r\nNote that \"running\" does not mean any of the task's code is currently loaded or activity -- the task may have been\r\nfrozen by the system, so that it can be restarted in its previous state when next brought to the foreground.\r\nNote: this method is only intended for debugging and presenting task management user interfaces. This\r\nshould never be used for core logic in an application, such as deciding between different behaviors based on the\r\ninformation found here. Such uses are not supported, and will likely break in the future. For example, if multiple\r\napplications can be actively running at the same time, assumptions made about the meaning of the data here for\r\npurposes of control flow will be incorrect.\r\nParameters\r\nmax\r\nNum\r\nint : The maximum number of entries to return in the list. The actual number returned may be\r\nsmaller, depending on how many tasks the user has started.\r\nisActivityStartAllowedOnDisplay\r\npublic boolean isActivityStartAllowedOnDisplay (Context context,\r\n int displayId,\r\n Intent intent)\r\nCheck if the context is allowed to start an activity on specified display. Some launch restrictions may apply to\r\nsecondary displays that are private, virtual, or owned by the system, in which case an activity start may throw a\r\nSecurityException . Call this method prior to starting an activity on a secondary display to check if the current\r\ncontext has access to it.\r\nParameters\r\ncontext\r\nContext : Source context, from which an activity will be started.\r\nThis value cannot be null .\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 17 of 22\n\ndisplayId int : Target display id.\r\nintent\r\nIntent : Intent used to launch an activity.\r\nThis value cannot be null .\r\nReturns\r\nboolean\r\ntrue if a call to start an activity on the target display is allowed for the provided context and\r\nno SecurityException will be thrown, false otherwise.\r\nisBackgroundRestricted\r\npublic boolean isBackgroundRestricted ()\r\nQuery whether the user has enabled background restrictions for this app.\r\nThe user may chose to do this, if they see that an app is consuming an unreasonable amount of battery while in the\r\nbackground.\r\nIf true, any work that the app tries to do will be aggressively restricted while it is in the background. At a\r\nminimum, jobs and alarms will not execute and foreground services cannot be started unless an app activity is in\r\nthe foreground.\r\nNote that these restrictions stay in effect even when the device is charging.\r\nReturns\r\nboolean true if user has enforced background restrictions for this app, false otherwise.\r\nisInLockTaskMode\r\npublic boolean isInLockTaskMode ()\r\nThis method was deprecated in API level 23.\r\nUse getLockTaskModeState() instead.\r\nReturn whether currently in lock task mode. When in this mode no new tasks can be created or switched to.\r\nisLowMemoryKillReportSupported\r\npublic static boolean isLowMemoryKillReportSupported ()\r\nisLowRamDevice\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 18 of 22\n\npublic boolean isLowRamDevice ()\r\nReturns true if this is a low-RAM device. Exactly whether a device is low-RAM is ultimately up to the device\r\nconfiguration, but currently it generally means something with 1GB or less of RAM. This is mostly intended to be\r\nused by apps to determine whether they should turn off certain features that require more RAM.\r\nisRunningInTestHarness\r\npublic static boolean isRunningInTestHarness ()\r\nThis method was deprecated in API level 29.\r\nthis method is false for all user builds. Users looking to check if their device is running in a device farm should\r\nsee isRunningInUserTestHarness() .\r\nReturns \"true\" if device is running in a test harness.\r\nisRunningInUserTestHarness\r\npublic static boolean isRunningInUserTestHarness ()\r\nReturns \"true\" if the device is running in Test Harness Mode.\r\nTest Harness Mode is a feature that allows devices to run without human interaction in a device farm/testing\r\nharness (such as Firebase Test Lab). You should check this method if you want your app to behave differently\r\nwhen running in a test harness to skip setup screens that would impede UI testing. e.g. a keyboard application that\r\nhas a full screen setup page for the first time it is launched.\r\nNote that you should not use this to determine whether or not your app is running an instrumentation test, as it is\r\nnot set for a standard device running a test.\r\nisUserAMonkey\r\npublic static boolean isUserAMonkey ()\r\nReturns \"true\" if the user interface is currently being messed with by a monkey.\r\nkillBackgroundProcesses\r\npublic void killBackgroundProcesses (String packageName)\r\nHave the system immediately kill all background processes associated with the given package. This is the same as\r\nthe kernel killing those processes to reclaim memory; the system will take care of restarting these processes in the\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 19 of 22\n\nfuture as needed.\r\nOn devices that run Android 14 or higher, third party applications can only use this API to kill their own\r\nprocesses.\r\n.\r\nRequires Manifest.permission.KILL_BACKGROUND_PROCESSES\r\nParameters\r\npackageName String : The name of the package whose processes are to be killed.\r\nmoveTaskToFront\r\npublic void moveTaskToFront (int taskId,\r\n int flags,\r\n Bundle options)\r\nAsk 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.\r\nRequires Manifest.permission.REORDER_TASKS\r\nregisterAnrWarningListener\r\npublic void registerAnrWarningListener (Executor executor,\r\n Consumer\u003cAnrWarningResult\u003e listener)\r\nRegisters a listener that is called when the app is close to the ANR timeout.\r\nThis is intended to give the app a chance to collect and store any additional information they may want to gather at\r\nthis time, or take any pre-ANR actions. Note that these listeners are called at best-effort, and may not be\r\nsuccessfully called (or be provided time to execute) before the ANR occurs and the app is killed.\r\nIf the app registers multiple distinct listeners, all registered listeners will be notified on the potential ANR\r\ncondition. The order in which listeners are notified is not guaranteed.\r\nThe app can unregister the listener using unregisterAnrWarningListener(Consumer) .\r\nParameters\r\nexecutor\r\nExecutor : The executor on which listener will be invoked. This should not be the\r\napplication's main thread.\r\nThis value cannot be null .\r\nlistener\r\nConsumer : The listener to be triggered on the ANR warning condition.\r\nThis value cannot be null .\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 20 of 22\n\nrestartPackage\r\npublic void restartPackage (String packageName)\r\nThis method was deprecated in API level 15.\r\nThis is now just a wrapper for killBackgroundProcesses(String) ; the previous behavior here is no longer\r\navailable to applications because it allows them to break other applications by removing their alarms, stopping\r\ntheir services, etc.\r\nParameters\r\npackageName String\r\nsetProcessStateSummary\r\npublic void setProcessStateSummary (byte[] state)\r\nSet custom state data for this process. It will be included in the record of ApplicationExitInfo on the death of\r\nthe current calling process; the new process of the app can retrieve this state data by calling\r\nApplicationExitInfo.getProcessStateSummary() on the record returned by\r\ngetHistoricalProcessExitReasons(String, int, int) .\r\nThis would be useful for the calling app to save its stateful data: if it's killed later for any reason, the new process\r\nof the app can know what the previous process of the app was doing. For instance, you could use this to encode\r\nthe current level in a game, or a set of features/experiments that were enabled. Later you could analyze under what\r\ncircumstances the app tends to crash or use too much memory. However, it's not suggested to rely on this to\r\nrestore the applications previous UI state or so, it's only meant for analyzing application healthy status.\r\nSystem might decide to throttle the calls to this API; so call this API in a reasonable manner, excessive calls to this\r\nAPI could result a RuntimeException .\r\nParameters\r\nstate\r\nbyte : The state data. To be advised, DO NOT include sensitive information/data (PII, SPII, or\r\nother sensitive user data) here. Maximum length is 128 bytes.\r\nThis value may be null .\r\nsetVrThread\r\npublic static void setVrThread (int tid)\r\nEnable more aggressive scheduling for latency-sensitive low-runtime VR threads. Only one thread can be a VR\r\nthread in a process at a time, and that thread may be subject to restrictions on the amount of time it can run. If\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 21 of 22\n\npersistent VR mode is set, whatever thread has been granted aggressive scheduling via this method will return to\r\nnormal operation, and calling this method will do nothing while persistent VR mode is enabled. To reset the VR\r\nthread for an application, a tid of 0 can be passed.\r\nParameters\r\ntid int : tid of the VR thread\r\nsetWatchHeapLimit\r\npublic void setWatchHeapLimit (long pssSize)\r\nRequest that the system start watching for the calling process to exceed a pss size as given here. Once called, the\r\nsystem will look for any occasions where it sees the associated process with a larger pss size and, when this\r\nhappens, automatically pull a heap dump from it and allow the user to share the data. Note that this request\r\ncontinues running even if the process is killed and restarted. To remove the watch, use clearWatchHeapLimit() .\r\nThis API only works if the calling process has been marked as ApplicationInfo.FLAG_DEBUGGABLE or this is\r\nrunning on a debuggable (userdebug or eng) build.\r\nCallers can optionally implement ACTION_REPORT_HEAP_LIMIT to directly handle heap limit reports themselves.\r\nParameters\r\npssSize long : The size in bytes to set the limit at.\r\nunregisterAnrWarningListener\r\npublic void unregisterAnrWarningListener (Consumer\u003cAnrWarningResult\u003e listener)\r\nUnregisters a previously registered ANR warning listener.\r\nSource: https://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nhttps://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29\r\nPage 22 of 22",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"origins": [
		"web"
	],
	"references": [
		"https://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29"
	],
	"report_names": [
		"ActivityManager.html#getRunningTasks%28int%29"
	],
	"threat_actors": [],
	"ts_created_at": 1775434675,
	"ts_updated_at": 1775826741,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/d760656e23d7e3e5579ffc89252c2c83539e9a85.pdf",
		"text": "https://archive.orkl.eu/d760656e23d7e3e5579ffc89252c2c83539e9a85.txt",
		"img": "https://archive.orkl.eu/d760656e23d7e3e5579ffc89252c2c83539e9a85.jpg"
	}
}