public class

ActivityManager

extends Object
java.lang.Object
   ↳ android.app.ActivityManager

Class Overview

Interact with the overall activities running in the system.

Summary

Nested Classes
public class ActivityManager.MemoryInfo Information you can retrieve about the available memory through getMemoryInfo(ActivityManager.MemoryInfo)
public class ActivityManager.ProcessErrorStateInfo Information you can retrieve about any processes that are in an error condition. 
public class ActivityManager.RecentTaskInfo Information you can retrieve about tasks that the user has most recently started or visited. 
public class ActivityManager.RunningAppProcessInfo Information you can retrieve about a running process. 
public class ActivityManager.RunningServiceInfo Information you can retrieve about a particular Service that is currently running in the system. 
public class ActivityManager.RunningTaskInfo Information you can retrieve about a particular task that is currently "running" in the system. 
Constants
int RECENT_WITH_EXCLUDED Flag for use with getRecentTasks(int, int): return all tasks, even those that have set their FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag.
Public Methods
ConfigurationInfo getDeviceConfigurationInfo()
Get the device configuration attributes.
void getMemoryInfo(ActivityManager.MemoryInfo outInfo)
List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
Returns a list of any processes that are currently in an error condition.
List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags)
Return a list of the tasks that the user has recently launched, with the most recent being first and older ones after in order.
List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
Returns a list of application processes that are running on the device.
List<ActivityManager.RunningServiceInfo> getRunningServices(int maxNum)
Return a list of the services that are currently running.
List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum)
Return a list of the tasks that are currently running, with the most recent being first and older ones after in order.
void restartPackage(String packageName)
Have the system perform a force stop of everything associated with the given application package.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int RECENT_WITH_EXCLUDED

Flag for use with getRecentTasks(int, int): return all tasks, even those that have set their FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag.

Constant Value: 1 (0x00000001)

Public Methods

public ConfigurationInfo getDeviceConfigurationInfo ()

Get the device configuration attributes.

public void getMemoryInfo (ActivityManager.MemoryInfo outInfo)

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.

Returns
  • Returns a list of ProcessErrorStateInfo records, or null if there are no current error conditions (it will not return an empty list). This list ordering is not specified.

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

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

Parameters
maxNum 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.
Returns
  • Returns a list of RecentTaskInfo records describing each of the recent tasks.
Throws
SecurityException Throws SecurityException if the caller does not hold the GET_TASKS permission.

public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses ()

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

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

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

Return a list of the services that are currently running.

Parameters
maxNum The maximum number of entries to return in the list. The actual number returned may be smaller, depending on how many services are running.
Returns
  • Returns a list of RunningServiceInfo records describing each of the running tasks.

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

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.

Parameters
maxNum 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.
Returns
  • Returns a list of RunningTaskInfo records describing each of the running tasks.
Throws
SecurityException Throws SecurityException if the caller does not hold the GET_TASKS permission.

public void restartPackage (String packageName)

Have the system perform a force stop of everything associated with the given application package. All processes that share its uid will be killed, all services it has running stopped, all activities removed, etc. In addition, a ACTION_PACKAGE_RESTARTED broadcast will be sent, so that any of its registered alarms can be stopped, notifications removed, etc.

You must hold the permission RESTART_PACKAGES to be able to call this method.

Parameters
packageName The name of the package to be stopped.