IT. Expert System.

Android Reference

ActivityManager


android.app

Class ActivityManager



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

      • START_CANCELED

        public static final int START_CANCELED
        Result for IActivityManager.startActivity: an error where the start had to be canceled.
        See Also:
        Constant Field Values
      • START_NOT_ACTIVITY

        public static final int START_NOT_ACTIVITY
        Result for IActivityManager.startActivity: an error where the thing being started is not an activity.
        See Also:
        Constant Field Values
      • START_PERMISSION_DENIED

        public static final int START_PERMISSION_DENIED
        Result for IActivityManager.startActivity: an error where the caller does not have permission to start the activity.
        See Also:
        Constant Field Values
      • START_FORWARD_AND_REQUEST_CONFLICT

        public static final int START_FORWARD_AND_REQUEST_CONFLICT
        Result for IActivityManager.startActivity: an error where the caller has requested both to forward a result and to receive a result.
        See Also:
        Constant Field Values
      • START_CLASS_NOT_FOUND

        public static final int START_CLASS_NOT_FOUND
        Result for IActivityManager.startActivity: an error where the requested class is not found.
        See Also:
        Constant Field Values
      • START_INTENT_NOT_RESOLVED

        public static final int START_INTENT_NOT_RESOLVED
        Result for IActivityManager.startActivity: an error where the given Intent could not be resolved to an activity.
        See Also:
        Constant Field Values
      • START_SUCCESS

        public static final int START_SUCCESS
        Result for IActivityManaqer.startActivity: the activity was started successfully as normal.
        See Also:
        Constant Field Values
      • START_RETURN_INTENT_TO_CALLER

        public static final int START_RETURN_INTENT_TO_CALLER
        Result for IActivityManaqer.startActivity: the caller asked that the Intent not be executed if it is the recipient, and that is indeed the case.
        See Also:
        Constant Field Values
      • START_TASK_TO_FRONT

        public static final int START_TASK_TO_FRONT
        Result for IActivityManaqer.startActivity: activity wasn't really started, but a task was simply brought to the foreground.
        See Also:
        Constant Field Values
      • START_DELIVERED_TO_TOP

        public static final int START_DELIVERED_TO_TOP
        Result for IActivityManaqer.startActivity: activity wasn't really started, but the given Intent was given to the existing top activity.
        See Also:
        Constant Field Values
      • START_SWITCHES_CANCELED

        public static final int START_SWITCHES_CANCELED
        Result for IActivityManaqer.startActivity: request was canceled because app switches are temporarily canceled to ensure the user's last request (such as pressing home) is performed.
        See Also:
        Constant Field Values
      • START_FLAG_ONLY_IF_NEEDED

        public static final int START_FLAG_ONLY_IF_NEEDED
        Flag for IActivityManaqer.startActivity: do special start mode where a new activity is launched only if it is needed.
        See Also:
        Constant Field Values
      • START_FLAG_DEBUG

        public static final int START_FLAG_DEBUG
        Flag for IActivityManaqer.startActivity: launch the app for debugging.
        See Also:
        Constant Field Values
      • START_FLAG_OPENGL_TRACES

        public static final int START_FLAG_OPENGL_TRACES
        Flag for IActivityManaqer.startActivity: launch the app for OpenGL tracing.
        See Also:
        Constant Field Values
      • START_FLAG_AUTO_STOP_PROFILER

        public static final int START_FLAG_AUTO_STOP_PROFILER
        Flag for IActivityManaqer.startActivity: if the app is being launched for profiling, automatically stop the profiler once done.
        See Also:
        Constant Field Values
      • BROADCAST_SUCCESS

        public static final int BROADCAST_SUCCESS
        Result for IActivityManaqer.broadcastIntent: success!
        See Also:
        Constant Field Values
      • BROADCAST_STICKY_CANT_HAVE_PERMISSION

        public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION
        Result for IActivityManaqer.broadcastIntent: attempt to broadcast a sticky intent without appropriate permission.
        See Also:
        Constant Field Values
      • INTENT_SENDER_BROADCAST

        public static final int INTENT_SENDER_BROADCAST
        Type for IActivityManaqer.getIntentSender: this PendingIntent is for a sendBroadcast operation.
        See Also:
        Constant Field Values
      • INTENT_SENDER_ACTIVITY

        public static final int INTENT_SENDER_ACTIVITY
        Type for IActivityManaqer.getIntentSender: this PendingIntent is for a startActivity operation.
        See Also:
        Constant Field Values
      • INTENT_SENDER_ACTIVITY_RESULT

        public static final int INTENT_SENDER_ACTIVITY_RESULT
        Type for IActivityManaqer.getIntentSender: this PendingIntent is for an activity result operation.
        See Also:
        Constant Field Values
      • INTENT_SENDER_SERVICE

        public static final int INTENT_SENDER_SERVICE
        Type for IActivityManaqer.getIntentSender: this PendingIntent is for a startService operation.
        See Also:
        Constant Field Values
      • COMPAT_MODE_ALWAYS

        public static final int COMPAT_MODE_ALWAYS
        Screen compatibility mode: the application most always run in compatibility mode.
        See Also:
        Constant Field Values
      • COMPAT_MODE_NEVER

        public static final int COMPAT_MODE_NEVER
        Screen compatibility mode: the application can never run in compatibility mode.
        See Also:
        Constant Field Values
      • COMPAT_MODE_UNKNOWN

        public static final int COMPAT_MODE_UNKNOWN
        Screen compatibility mode: unknown.
        See Also:
        Constant Field Values
      • COMPAT_MODE_DISABLED

        public static final int COMPAT_MODE_DISABLED
        Screen compatibility mode: the application currently has compatibility mode disabled.
        See Also:
        Constant Field Values
      • COMPAT_MODE_ENABLED

        public static final int COMPAT_MODE_ENABLED
        Screen compatibility mode: the application currently has compatibility mode enabled.
        See Also:
        Constant Field Values
      • COMPAT_MODE_TOGGLE

        public static final int COMPAT_MODE_TOGGLE
        Screen compatibility mode: request to toggle the application's compatibility mode.
        See Also:
        Constant Field Values
      • RECENT_IGNORE_UNAVAILABLE

        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.
        See Also:
        Constant Field Values
      • REMOVE_TASK_KILL_PROCESS

        public static final int REMOVE_TASK_KILL_PROCESS
        If set, the process of the root activity of the task will be killed as part of removing the task.
        See Also:
        Constant Field Values
      • MOVE_TASK_WITH_HOME

        public static final int MOVE_TASK_WITH_HOME
        Flag for moveTaskToFront(int, int): also move the "home" activity along with the task, so it is positioned immediately behind the task.
        See Also:
        Constant Field Values
      • MOVE_TASK_NO_USER_ACTION

        public static final int MOVE_TASK_NO_USER_ACTION
        Flag for moveTaskToFront(int, int): don't count this as a user-instigated action, so the current activity will not receive a hint that the user is leaving.
        See Also:
        Constant Field Values
    • Method Detail

      • getFrontActivityScreenCompatMode

        public int getFrontActivityScreenCompatMode()
      • setFrontActivityScreenCompatMode

        public void setFrontActivityScreenCompatMode(int mode)
      • getPackageScreenCompatMode

        public int getPackageScreenCompatMode(String packageName)
      • setPackageScreenCompatMode

        public void setPackageScreenCompatMode(String packageName,
                                      int mode)
      • getPackageAskScreenCompat

        public boolean getPackageAskScreenCompat(String packageName)
      • setPackageAskScreenCompat

        public void setPackageAskScreenCompat(String packageName,
                                     boolean ask)
      • getMemoryClass

        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 device with more memory may return 24 or even higher numbers.
      • staticGetMemoryClass

        public static int staticGetMemoryClass()
      • getLargeMemoryClass

        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 getMemoryClass() limit. The returned value is in megabytes. This may be the same size as getMemoryClass() on memory constrained devices, or it may be significantly larger on devices with a large amount of available RAM.

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

      • staticGetLargeMemoryClass

        public static int staticGetLargeMemoryClass()
      • isHighEndGfx

        public static boolean isHighEndGfx()
        Used by persistent processes to determine if they are running on a higher-end device so should be okay using hardware drawing acceleration (which tends to consume a lot more RAM).
      • isLargeRAM

        public static boolean isLargeRAM()
        Use to decide whether the running device can be considered a "large RAM" device. Exactly what memory limit large RAM is will vary, but it essentially means there is plenty of RAM to have lots of background processes running under decent loads.
      • getRecentTasks

        public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
                                                          int flags)
                                                            throws SecurityException
        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.

        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.
        flags - Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and RECENT_IGNORE_UNAVAILABLE.
        Returns:
        Returns a list of RecentTaskInfo records describing each of the recent tasks.
        Throws:
        SecurityException - Throws SecurityException if the caller does not hold the android.Manifest.permission#GET_TASKS permission.
      • getRecentTasksForUser

        public List<ActivityManager.RecentTaskInfo> getRecentTasksForUser(int maxNum,
                                                                 int flags,
                                                                 int userId)
                                                                   throws SecurityException
        Same as getRecentTasks(int, int) but returns the recent tasks for a specific user. It requires holding the android.Manifest.permission#INTERACT_ACROSS_USERS_FULL permission.
        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.
        flags - Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and RECENT_IGNORE_UNAVAILABLE.
        Returns:
        Returns a list of RecentTaskInfo records describing each of the recent tasks.
        Throws:
        SecurityException - Throws SecurityException if the caller does not hold the android.Manifest.permission#GET_TASKS or the android.Manifest.permission#INTERACT_ACROSS_USERS_FULL permissions.
      • getRunningTasks

        public List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum,
                                                            int flags,
                                                            IThumbnailReceiver receiver)
                                                              throws SecurityException
        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.
        flags - Optional flags
        receiver - Optional receiver for delayed thumbnails
        Returns:
        Returns a list of RunningTaskInfo records describing each of the running tasks. Some thumbnails may not be available at the time of this call. The optional receiver may be used to receive those thumbnails.
        Throws:
        SecurityException - Throws SecurityException if the caller does not hold the android.Manifest.permission#GET_TASKS permission.
      • getRunningTasks

        public List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum)
                                                              throws SecurityException
        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.

        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 android.Manifest.permission#GET_TASKS permission.
      • removeSubTask

        public boolean removeSubTask(int taskId,
                            int subTaskIndex)
                              throws SecurityException
        Remove some end of a task's activity stack that is not part of the main application. The selected activities will be finished, so they are no longer part of the main task.
        Parameters:
        taskId - The identifier of the task.
        subTaskIndex - The number of the sub-task; this corresponds to the index of the thumbnail returned by getTaskThumbnails(int).
        Returns:
        Returns true if the sub-task was found and was removed.
        Throws:
        SecurityException
      • removeTask

        public boolean removeTask(int taskId,
                         int flags)
                           throws SecurityException
        Completely remove the given task.
        Parameters:
        taskId - Identifier of the task to be removed.
        flags - Additional operational flags. May be 0 or REMOVE_TASK_KILL_PROCESS.
        Returns:
        Returns true if the given task was found and removed.
        Throws:
        SecurityException
      • moveTaskToFront

        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 that the caller hold permission android.Manifest.permission#REORDER_TASKS or a SecurityException will be thrown.
        Parameters:
        taskId - The identifier of the task to be moved, as found in ActivityManager.RunningTaskInfo or ActivityManager.RecentTaskInfo.
        flags - Additional operational flags, 0 or more of MOVE_TASK_WITH_HOME.
        options - Additional options for the operation, either null or as per Context.startActivity(Intent, Bundle).
      • getRunningServices

        public List<ActivityManager.RunningServiceInfo> getRunningServices(int maxNum)
                                                                    throws SecurityException
        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.

        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.
        Throws:
        SecurityException
      • getRunningServiceControlPanel

        public PendingIntent getRunningServiceControlPanel(ComponentName service)
                                                    throws SecurityException
        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.
        Throws:
        SecurityException
      • clearApplicationUserData

        public boolean clearApplicationUserData(String packageName,
                                       IPackageDataObserver observer)
      • getProcessesInErrorState

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

        public List<ApplicationInfo> getRunningExternalApplications()
        Returns a list of application processes installed on external media that are running on the device.

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

        Returns:
        Returns a list of ApplicationInfo records, or null if none This list ordering is not specified.
      • getRunningAppProcesses

        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.

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

        public Debug.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.

        Parameters:
        pids - The pids of the processes whose memory usage is to be retrieved.
        Returns:
        Returns an array of memory information, one for each requested pid.
      • restartPackage

        @Deprecated
        public void restartPackage(String packageName)
        Deprecated. This is now just a wrapper for killBackgroundProcesses(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.
      • killBackgroundProcesses

        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.

        You must hold the permission android.Manifest.permission#KILL_BACKGROUND_PROCESSES to be able to call this method.

        Parameters:
        packageName - The name of the package whose processes are to be killed.
      • forceStopPackage

        public void forceStopPackage(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 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 android.Manifest.permission#FORCE_STOP_PACKAGES to be able to call this method.

        Parameters:
        packageName - The name of the package to be stopped.
      • getDeviceConfigurationInfo

        public ConfigurationInfo getDeviceConfigurationInfo()
        Get the device configuration attributes.
      • getLauncherLargeIconDensity

        public int getLauncherLargeIconDensity()
        Get the preferred density of icons for the launcher. This is used when custom drawables are created (e.g., for shortcuts).
        Returns:
        density in terms of DPI
      • getLauncherLargeIconSize

        public int getLauncherLargeIconSize()
        Get the preferred launcher icon size. This is used when custom drawables are created (e.g., for shortcuts).
        Returns:
        dimensions of square icons in terms of pixels
      • isUserAMonkey

        public static boolean isUserAMonkey()
        Returns "true" if the user interface is currently being messed with by a monkey.
      • isRunningInTestHarness

        public static boolean isRunningInTestHarness()
        Returns "true" if device is running in a test harness.
      • getAllPackageLaunchCounts

        public Map<String,Integer> getAllPackageLaunchCounts()
        Returns the launch count of each installed package.
      • checkComponentPermission

        public static int checkComponentPermission(String permission,
                                   int uid,
                                   int owningUid,
                                   boolean exported)
      • checkUidPermission

        public static int checkUidPermission(String permission,
                             int uid)
      • handleIncomingUser

        public static int handleIncomingUser(int callingPid,
                             int callingUid,
                             int userId,
                             boolean allowAll,
                             boolean requireFull,
                             String name,
                             String callerPackage)
      • getCurrentUser

        public static int getCurrentUser()
      • getAllPackageUsageStats

        public com.android.internal.os.PkgUsageStats[] getAllPackageUsageStats()
        Returns the usage statistics of each installed package.
      • switchUser

        public boolean switchUser(int userid)
        Parameters:
        userid - the user's id. Zero indicates the default user
      • isUserRunning

        public boolean isUserRunning(int userid)
        Return whether the given user is actively running. This means that the user is in the "started" state, not "stopped" -- it is currently allowed to run code through scheduled alarms, receiving broadcasts, etc. A started user may be either the current foreground user or a background user; the result here does not distinguish between the two.
        Parameters:
        userid - the user's id. Zero indicates the default user.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1440 / . Delta: 0.04705 с