FileDocCategorySizeDatePackage
ActivityManager.javaAPI DocAndroid 1.5 API25553Wed May 06 22:41:54 BST 2009android.app

ActivityManager

public class ActivityManager extends Object
Interact with the overall activities running in the system.

Fields Summary
private static String
TAG
private static boolean
DEBUG
private static boolean
localLOGV
private final android.content.Context
mContext
private final android.os.Handler
mHandler
public static final int
RECENT_WITH_EXCLUDED
Flag for use with {@link #getRecentTasks}: return all tasks, even those that have set their {@link android.content.Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS} flag.
Constructors Summary
ActivityManager(android.content.Context context, android.os.Handler handler)


    /*package*/     
        mContext = context;
        mHandler = handler;
    
Methods Summary
public booleanclearApplicationUserData(java.lang.String packageName, android.content.pm.IPackageDataObserver observer)

hide

        try {
            return ActivityManagerNative.getDefault().clearApplicationUserData(packageName, 
                    observer);
        } catch (RemoteException e) {
            return false;
        }
    
public android.content.pm.ConfigurationInfogetDeviceConfigurationInfo()
Get the device configuration attributes.

        try {
            return ActivityManagerNative.getDefault().getDeviceConfigurationInfo();
        } catch (RemoteException e) {
        }
        return null;
    
public voidgetMemoryInfo(android.app.ActivityManager$MemoryInfo outInfo)

        try {
            ActivityManagerNative.getDefault().getMemoryInfo(outInfo);
        } catch (RemoteException e) {
        }
    
public java.util.ListgetProcessesInErrorState()
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.

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

        try {
            return ActivityManagerNative.getDefault().getProcessesInErrorState();
        } catch (RemoteException e) {
            return null;
        }
    
public java.util.ListgetRecentTasks(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.

param
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.
return
Returns a list of RecentTaskInfo records describing each of the recent tasks.
throws
SecurityException Throws SecurityException if the caller does not hold the {@link android.Manifest.permission#GET_TASKS} permission.

    
                                                                                                    
         
              
        try {
            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
                    flags);
        } catch (RemoteException e) {
            // System dead, we will be dead too soon!
            return null;
        }
    
public java.util.ListgetRunningAppProcesses()
Returns a list of application processes that are running on the device.

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

        try {
            return ActivityManagerNative.getDefault().getRunningAppProcesses();
        } catch (RemoteException e) {
            return null;
        }
    
public java.util.ListgetRunningServices(int maxNum)
Return a list of the services that are currently running.

param
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.
return
Returns a list of RunningServiceInfo records describing each of the running tasks.

        try {
            return (List<RunningServiceInfo>)ActivityManagerNative.getDefault()
                    .getServices(maxNum, 0);
        } catch (RemoteException e) {
            // System dead, we will be dead too soon!
            return null;
        }
    
public java.util.ListgetRunningTasks(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.

param
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.
return
Returns a list of RunningTaskInfo records describing each of the running tasks.
throws
SecurityException Throws SecurityException if the caller does not hold the {@link android.Manifest.permission#GET_TASKS} permission.

        try {
            return (List<RunningTaskInfo>)ActivityManagerNative.getDefault()
                    .getTasks(maxNum, 0, null);
        } catch (RemoteException e) {
            // System dead, we will be dead too soon!
            return null;
        }
    
public voidrestartPackage(java.lang.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 {@link Intent#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 {@link android.Manifest.permission#RESTART_PACKAGES} to be able to call this method.

param
packageName The name of the package to be stopped.

        try {
            ActivityManagerNative.getDefault().restartPackage(packageName);
        } catch (RemoteException e) {
        }