public class ActivityManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ActivityManager.AppTask
The AppTask allows you to manage your own application's tasks.
|
static interface |
ActivityManager.BugreportMode
Defines acceptable types of bugreports.
|
static class |
ActivityManager.MemoryInfo
Information you can retrieve about the available memory through
getMemoryInfo(android.app.ActivityManager.MemoryInfo) . |
static class |
ActivityManager.ProcessErrorStateInfo
Information you can retrieve about any processes that are in an error condition.
|
static class |
ActivityManager.RecentTaskInfo
Information you can retrieve about tasks that the user has most recently
started or visited.
|
static class |
ActivityManager.RunningAppProcessInfo
Information you can retrieve about a running process.
|
static class |
ActivityManager.RunningServiceInfo
Information you can retrieve about a particular Service that is
currently running in the system.
|
static class |
ActivityManager.RunningTaskInfo
Information you can retrieve about a particular task that is currently
"running" in the system.
|
static class |
ActivityManager.StackId |
static class |
ActivityManager.StackInfo
Information you can retrieve about an ActivityStack in the system.
|
static class |
ActivityManager.TaskDescription
Information you can set and retrieve about the current activity within the recent task list.
|
static class |
ActivityManager.TaskThumbnail |
static class |
ActivityManager.TaskThumbnailInfo
Metadata related to the
ActivityManager.TaskThumbnail . |
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_REPORT_HEAP_LIMIT
Action an app can implement to handle reports from
setWatchHeapLimit(long) . |
static int |
APP_START_MODE_DELAYED |
static int |
APP_START_MODE_DISABLED |
static int |
APP_START_MODE_NORMAL |
static int |
ASSIST_CONTEXT_BASIC |
static int |
ASSIST_CONTEXT_FULL |
static int |
BROADCAST_FAILED_USER_STOPPED
Result for IActivityManager.broadcastIntent: trying to send a broadcast
to a stopped user.
|
static int |
BROADCAST_STICKY_CANT_HAVE_PERMISSION
Result for IActivityManaqer.broadcastIntent: attempt to broadcast
a sticky intent without appropriate permission.
|
static int |
BROADCAST_SUCCESS
Result for IActivityManaqer.broadcastIntent: success!
|
static int |
BUGREPORT_OPTION_FULL
Takes a bugreport without user interference (and hence causing less
interference to the system), but includes all sections.
|
static int |
BUGREPORT_OPTION_INTERACTIVE
Allows user to monitor progress and enter additional data; might not include all
sections.
|
static int |
BUGREPORT_OPTION_REMOTE
Takes a bugreport requested remotely by administrator of the Device Owner app,
not the device's user.
|
static int |
BUGREPORT_OPTION_WEAR
Takes a bugreport on a wearable device.
|
static int |
COMPAT_MODE_ALWAYS
Screen compatibility mode: the application most always run in
compatibility mode.
|
static int |
COMPAT_MODE_DISABLED
Screen compatibility mode: the application currently has compatibility
mode disabled.
|
static int |
COMPAT_MODE_ENABLED
Screen compatibility mode: the application currently has compatibility
mode enabled.
|
static int |
COMPAT_MODE_NEVER
Screen compatibility mode: the application can never run in
compatibility mode.
|
static int |
COMPAT_MODE_TOGGLE
Screen compatibility mode: request to toggle the application's
compatibility mode.
|
static int |
COMPAT_MODE_UNKNOWN
Screen compatibility mode: unknown.
|
static int |
DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT
Input parameter to
IActivityManager.moveTaskToDockedStack(int, int, boolean, boolean, android.graphics.Rect, boolean) which
specifies the position of the created docked stack at the bottom half of the screen if
in portrait mode or at the right half of the screen if in landscape mode. |
static int |
DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
Input parameter to
IActivityManager.moveTaskToDockedStack(int, int, boolean, boolean, android.graphics.Rect, boolean) which
specifies the position of the created docked stack at the top half of the screen if
in portrait mode or at the left half of the screen if in landscape mode. |
static int |
FLAG_AND_LOCKED |
static int |
FLAG_AND_UNLOCKED |
static int |
FLAG_AND_UNLOCKING_OR_UNLOCKED |
static int |
FLAG_OR_STOPPED |
static int |
INTENT_SENDER_ACTIVITY
Type for IActivityManaqer.getIntentSender: this PendingIntent is
for a startActivity operation.
|
static int |
INTENT_SENDER_ACTIVITY_RESULT
Type for IActivityManaqer.getIntentSender: this PendingIntent is
for an activity result operation.
|
static int |
INTENT_SENDER_BROADCAST
Type for IActivityManaqer.getIntentSender: this PendingIntent is
for a sendBroadcast operation.
|
static int |
INTENT_SENDER_SERVICE
Type for IActivityManaqer.getIntentSender: this PendingIntent is
for a startService operation.
|
static int |
LOCK_TASK_MODE_LOCKED
Full lock task mode is active.
|
static int |
LOCK_TASK_MODE_NONE
Lock task mode is not active.
|
static int |
LOCK_TASK_MODE_PINNED
App pinning mode is active.
|
static int |
MAX_PROCESS_STATE |
static String |
META_HOME_ALTERNATE
<meta-data> name for a 'home' Activity that declares a package that is to be
uninstalled in lieu of the declaring one. |
static int |
MIN_PROCESS_STATE |
static 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. |
static 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. |
static int |
PROCESS_STATE_BACKUP |
static int |
PROCESS_STATE_BOUND_FOREGROUND_SERVICE |
static int |
PROCESS_STATE_CACHED_ACTIVITY |
static int |
PROCESS_STATE_CACHED_ACTIVITY_CLIENT |
static int |
PROCESS_STATE_CACHED_EMPTY |
static int |
PROCESS_STATE_FOREGROUND_SERVICE |
static int |
PROCESS_STATE_HEAVY_WEIGHT |
static int |
PROCESS_STATE_HOME |
static int |
PROCESS_STATE_IMPORTANT_BACKGROUND |
static int |
PROCESS_STATE_IMPORTANT_FOREGROUND |
static int |
PROCESS_STATE_LAST_ACTIVITY |
static int |
PROCESS_STATE_NONEXISTENT |
static int |
PROCESS_STATE_PERSISTENT |
static int |
PROCESS_STATE_PERSISTENT_UI |
static int |
PROCESS_STATE_RECEIVER |
static int |
PROCESS_STATE_SERVICE |
static int |
PROCESS_STATE_TOP |
static int |
PROCESS_STATE_TOP_SLEEPING |
static int |
RECENT_IGNORE_HOME_STACK_TASKS
Ignores all tasks that are on the home stack.
|
static int |
RECENT_IGNORE_UNAVAILABLE
Provides a list that does not contain any
recent tasks that currently are not available to the user.
|
static int |
RECENT_INCLUDE_PROFILES
Provides a list that contains recent tasks for all
profiles of a user.
|
static int |
RECENT_INGORE_DOCKED_STACK_TOP_TASK
Ignores the top task in the docked stack.
|
static int |
RECENT_INGORE_PINNED_STACK_TASKS
Ignores all tasks that are on the pinned stack.
|
static int |
RECENT_WITH_EXCLUDED
Flag for use with
getRecentTasks(int, int) : return all tasks, even those
that have set their
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag. |
static int |
RESIZE_MODE_FORCED
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) which indicates
that the resize should be performed even if the bounds appears unchanged. |
static int |
RESIZE_MODE_PRESERVE_WINDOW
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) which indicates
that the resize should preserve the window if possible. |
static int |
RESIZE_MODE_SYSTEM
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) which indicates
that the resize doesn't need to preserve the window, and can be skipped if bounds
is unchanged. |
static int |
RESIZE_MODE_SYSTEM_SCREEN_ROTATION
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) used by window
manager during a screen rotation. |
static int |
RESIZE_MODE_USER
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) used when the
resize is due to a drag action. |
static int |
RESIZE_MODE_USER_FORCED
Input parameter to
IActivityManager.resizeTask(int, android.graphics.Rect, int) which indicates
that the resize should preserve the window if possible, and should not be skipped
even if the bounds is unchanged. |
static int |
START_CANCELED
Result for IActivityManager.startActivity: an error where the
start had to be canceled.
|
static int |
START_CLASS_NOT_FOUND
Result for IActivityManager.startActivity: an error where the
requested class is not found.
|
static 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.
|
static int |
START_FLAG_DEBUG
Flag for IActivityManaqer.startActivity: launch the app for
debugging.
|
static int |
START_FLAG_NATIVE_DEBUGGING
Flag for IActivityManaqer.startActivity: launch the app with
native debugging support.
|
static 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.
|
static int |
START_FLAG_TRACK_ALLOCATION
Flag for IActivityManaqer.startActivity: launch the app for
allocation tracking.
|
static 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.
|
static int |
START_INTENT_NOT_RESOLVED
Result for IActivityManager.startActivity: an error where the
given Intent could not be resolved to an activity.
|
static int |
START_NOT_ACTIVITY
Result for IActivityManager.startActivity: an error where the
thing being started is not an activity.
|
static int |
START_NOT_CURRENT_USER_ACTIVITY
Result for IActivityManager.startActivity: trying to start a background user
activity that shouldn't be displayed for all users.
|
static int |
START_NOT_VOICE_COMPATIBLE
Result for IActivityManager.startActivity: trying to start an activity under voice
control when that activity does not support the VOICE category.
|
static int |
START_PERMISSION_DENIED
Result for IActivityManager.startActivity: an error where the
caller does not have permission to start the activity.
|
static 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.
|
static int |
START_RETURN_LOCK_TASK_MODE_VIOLATION
Result for IActivityManaqer.startActivity: a new activity was attempted to be started
while in Lock Task Mode.
|
static int |
START_SUCCESS
Result for IActivityManaqer.startActivity: the activity was started
successfully as normal.
|
static 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.
|
static int |
START_TASK_TO_FRONT
Result for IActivityManaqer.startActivity: activity wasn't really started, but
a task was simply brought to the foreground.
|
static int |
START_VOICE_HIDDEN_SESSION
Result for IActivityManager.startVoiceActivity: active session is currently hidden.
|
static int |
START_VOICE_NOT_ACTIVE_SESSION
Result for IActivityManager.startVoiceActivity: active session does not match
the requesting token.
|
static int |
UID_OBSERVER_ACTIVE |
static int |
UID_OBSERVER_GONE |
static int |
UID_OBSERVER_IDLE |
static int |
UID_OBSERVER_PROCSTATE |
static int |
USER_OP_ERROR_IS_SYSTEM |
static int |
USER_OP_ERROR_RELATED_USERS_CANNOT_STOP |
static int |
USER_OP_IS_CURRENT |
static int |
USER_OP_SUCCESS |
static int |
USER_OP_UNKNOWN_USER |
Modifier and Type | Method and Description |
---|---|
int |
addAppTask(Activity activity,
Intent intent,
ActivityManager.TaskDescription description,
Bitmap thumbnail)
Add a new
ActivityManager.AppTask for the calling application. |
static int |
checkComponentPermission(String permission,
int uid,
int owningUid,
boolean exported) |
static int |
checkUidPermission(String permission,
int uid) |
boolean |
clearApplicationUserData()
Permits an application to erase its own data from disk.
|
boolean |
clearApplicationUserData(String packageName,
IPackageDataObserver observer) |
void |
clearGrantedUriPermissions(String packageName)
Permits an application to clear the persistent URI permissions granted to another.
|
void |
clearWatchHeapLimit()
Clear a heap watch limit previously set by
setWatchHeapLimit(long) . |
void |
dumpPackageState(FileDescriptor fd,
String packageName)
Perform a system dump of various state associated with the given application
package name.
|
static void |
dumpPackageStateStatic(FileDescriptor fd,
String packageName) |
void |
forceStopPackage(String packageName) |
void |
forceStopPackageAsUser(String packageName,
int userId)
Have the system perform a force stop of everything associated with
the given application package.
|
List<ActivityManager.AppTask> |
getAppTasks()
Get the list of tasks associated with the calling application.
|
Size |
getAppTaskThumbnailSize()
Return the current design dimensions for
ActivityManager.AppTask thumbnails, for use
with addAppTask(android.app.Activity, android.content.Intent, android.app.ActivityManager.TaskDescription, android.graphics.Bitmap) . |
static int |
getCurrentUser()
Gets the userId of the current foreground user.
|
static int |
getDefaultAppRecentsLimitStatic()
Return the default limit on the number of recents that an app can make.
|
ConfigurationInfo |
getDeviceConfigurationInfo()
Get the device configuration attributes.
|
int |
getFrontActivityScreenCompatMode() |
ParceledListSlice<UriPermission> |
getGrantedUriPermissions(String packageName)
Permits an application to get the persistent URI permissions granted to another.
|
int |
getLargeMemoryClass()
Return the approximate per-application memory class of the current
device when an application is running with a large heap.
|
int |
getLauncherLargeIconDensity()
Get the preferred density of icons for the launcher.
|
int |
getLauncherLargeIconSize()
Get the preferred launcher icon size.
|
int |
getLockTaskModeState()
Return the current state of task locking.
|
static int |
getMaxAppRecentsLimitStatic()
Return the maximum limit on the number of recents that an app can make.
|
static int |
getMaxRecentTasksStatic()
Return the maximum number of recents entries that we will maintain and show.
|
int |
getMemoryClass()
Return the approximate per-application memory class of the current
device.
|
void |
getMemoryInfo(ActivityManager.MemoryInfo outInfo)
Return general information about the memory state of the system.
|
static void |
getMyMemoryState(ActivityManager.RunningAppProcessInfo outState)
Return global memory state information for the calling process.
|
boolean |
getPackageAskScreenCompat(String packageName) |
int |
getPackageImportance(String packageName)
Return the importance of a given package name, based on the processes that are
currently running.
|
int |
getPackageScreenCompatMode(String packageName) |
List<ActivityManager.ProcessErrorStateInfo> |
getProcessesInErrorState()
Returns a list of any processes that are currently in an error condition.
|
Debug.MemoryInfo[] |
getProcessMemoryInfo(int[] pids)
Return information about the memory usage of one or more processes.
|
List<ActivityManager.RecentTaskInfo> |
getRecentTasks(int maxNum,
int flags)
Deprecated.
As of
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 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. |
List<ActivityManager.RecentTaskInfo> |
getRecentTasksForUser(int maxNum,
int flags,
int userId)
Same as
getRecentTasks(int, int) but returns the recent tasks for a
specific user. |
List<ActivityManager.RunningAppProcessInfo> |
getRunningAppProcesses()
Returns a list of application processes that are running on the device.
|
List<ApplicationInfo> |
getRunningExternalApplications()
Returns a list of application processes installed on external media
that are running on the device.
|
PendingIntent |
getRunningServiceControlPanel(ComponentName service)
Returns a PendingIntent you can start to show a control panel for the
given running service.
|
List<ActivityManager.RunningServiceInfo> |
getRunningServices(int maxNum)
Return a list of the services that are currently running.
|
List<ActivityManager.RunningTaskInfo> |
getRunningTasks(int maxNum)
Deprecated.
As of
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 retu rn 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. |
ActivityManager.TaskThumbnail |
getTaskThumbnail(int id) |
static int |
handleIncomingUser(int callingPid,
int callingUid,
int userId,
boolean allowAll,
boolean requireFull,
String name,
String callerPackage) |
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).
|
boolean |
isInHomeStack(int taskId) |
boolean |
isInLockTaskMode()
Deprecated.
Use
getLockTaskModeState() instead. |
boolean |
isLowRamDevice()
Returns true if this is a low-RAM device.
|
static boolean |
isLowRamDeviceStatic() |
static boolean |
isProcStateBackground(int procState) |
static boolean |
isRunningInTestHarness()
Returns "true" if device is running in a test harness.
|
static boolean |
isUserAMonkey()
Returns "true" if the user interface is currently being messed with
by a monkey.
|
boolean |
isUserRunning(int userId)
Return whether the given user is actively running.
|
boolean |
isVrModePackageEnabled(ComponentName component) |
void |
killBackgroundProcesses(String packageName)
Have the system immediately kill all background processes associated
with the given package.
|
void |
killUid(int uid,
String reason)
Kills the specified UID.
|
static void |
logoutCurrentUser()
Logs out current current foreground user by switching to the system user and stopping the
user being switched from.
|
void |
moveTaskToFront(int taskId,
int flags)
Equivalent to calling
moveTaskToFront(int, int, Bundle)
with a null options argument. |
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.
|
boolean |
removeTask(int taskId)
Completely remove the given task.
|
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. |
void |
setFrontActivityScreenCompatMode(int mode) |
void |
setPackageAskScreenCompat(String packageName,
boolean ask) |
void |
setPackageScreenCompatMode(String packageName,
int mode) |
boolean |
setProcessMemoryTrimLevel(String process,
int userId,
int level)
Sets the memory trim mode for a process and schedules a memory trim operation.
|
static void |
setVrThread(int tid)
Enable more aggressive scheduling for latency-sensitive low-runtime VR threads.
|
void |
setWatchHeapLimit(long pssSize)
Request that the system start watching for the calling process to exceed a pss
size as given here.
|
void |
startLockTaskMode(int taskId) |
static int |
staticGetLargeMemoryClass() |
static int |
staticGetMemoryClass() |
void |
stopLockTaskMode() |
static boolean |
supportsMultiWindow()
Returns true if the system supports at least one form of multi-window.
|
boolean |
switchUser(int userid) |
public static final int BUGREPORT_OPTION_FULL
public static final int BUGREPORT_OPTION_INTERACTIVE
public static final int BUGREPORT_OPTION_REMOTE
public static final int BUGREPORT_OPTION_WEAR
public static final String META_HOME_ALTERNATE
<meta-data>
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>
.public static final int START_VOICE_HIDDEN_SESSION
public static final int START_VOICE_NOT_ACTIVE_SESSION
public static final int START_NOT_CURRENT_USER_ACTIVITY
public static final int START_NOT_VOICE_COMPATIBLE
public static final int START_CANCELED
public static final int START_NOT_ACTIVITY
public static final int START_PERMISSION_DENIED
public static final int START_FORWARD_AND_REQUEST_CONFLICT
public static final int START_CLASS_NOT_FOUND
public static final int START_INTENT_NOT_RESOLVED
public static final int START_SUCCESS
public static final int START_RETURN_INTENT_TO_CALLER
public static final int START_TASK_TO_FRONT
public static final int START_DELIVERED_TO_TOP
public static final int START_SWITCHES_CANCELED
public static final int START_RETURN_LOCK_TASK_MODE_VIOLATION
public static final int START_FLAG_ONLY_IF_NEEDED
public static final int START_FLAG_DEBUG
public static final int START_FLAG_TRACK_ALLOCATION
public static final int START_FLAG_NATIVE_DEBUGGING
public static final int BROADCAST_SUCCESS
public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION
public static final int BROADCAST_FAILED_USER_STOPPED
public static final int INTENT_SENDER_BROADCAST
public static final int INTENT_SENDER_ACTIVITY
public static final int INTENT_SENDER_ACTIVITY_RESULT
public static final int INTENT_SENDER_SERVICE
public static final int USER_OP_SUCCESS
public static final int USER_OP_UNKNOWN_USER
public static final int USER_OP_IS_CURRENT
public static final int USER_OP_ERROR_IS_SYSTEM
public static final int USER_OP_ERROR_RELATED_USERS_CANNOT_STOP
public static final int PROCESS_STATE_NONEXISTENT
public static final int PROCESS_STATE_PERSISTENT
public static final int PROCESS_STATE_PERSISTENT_UI
public static final int PROCESS_STATE_TOP
public static final int PROCESS_STATE_BOUND_FOREGROUND_SERVICE
public static final int PROCESS_STATE_FOREGROUND_SERVICE
public static final int PROCESS_STATE_TOP_SLEEPING
public static final int PROCESS_STATE_IMPORTANT_FOREGROUND
public static final int PROCESS_STATE_IMPORTANT_BACKGROUND
public static final int PROCESS_STATE_BACKUP
public static final int PROCESS_STATE_HEAVY_WEIGHT
public static final int PROCESS_STATE_SERVICE
public static final int PROCESS_STATE_RECEIVER
public static final int PROCESS_STATE_HOME
public static final int PROCESS_STATE_LAST_ACTIVITY
public static final int PROCESS_STATE_CACHED_ACTIVITY
public static final int PROCESS_STATE_CACHED_ACTIVITY_CLIENT
public static final int PROCESS_STATE_CACHED_EMPTY
public static final int MIN_PROCESS_STATE
public static final int MAX_PROCESS_STATE
public static final int ASSIST_CONTEXT_BASIC
public static final int ASSIST_CONTEXT_FULL
public static final int UID_OBSERVER_PROCSTATE
public static final int UID_OBSERVER_GONE
public static final int UID_OBSERVER_IDLE
public static final int UID_OBSERVER_ACTIVE
public static final int APP_START_MODE_NORMAL
public static final int APP_START_MODE_DELAYED
public static final int APP_START_MODE_DISABLED
public static final int LOCK_TASK_MODE_NONE
public static final int LOCK_TASK_MODE_LOCKED
public static final int LOCK_TASK_MODE_PINNED
public static final int COMPAT_MODE_ALWAYS
public static final int COMPAT_MODE_NEVER
public static final int COMPAT_MODE_UNKNOWN
public static final int COMPAT_MODE_DISABLED
public static final int COMPAT_MODE_ENABLED
public static final int COMPAT_MODE_TOGGLE
public static final int DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
IActivityManager.moveTaskToDockedStack(int, int, boolean, boolean, android.graphics.Rect, boolean)
which
specifies the position of the created docked stack at the top half of the screen if
in portrait mode or at the left half of the screen if in landscape mode.public static final int DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT
IActivityManager.moveTaskToDockedStack(int, int, boolean, boolean, android.graphics.Rect, boolean)
which
specifies the position of the created docked stack at the bottom half of the screen if
in portrait mode or at the right half of the screen if in landscape mode.public static final int RESIZE_MODE_SYSTEM
IActivityManager.resizeTask(int, android.graphics.Rect, int)
which indicates
that the resize doesn't need to preserve the window, and can be skipped if bounds
is unchanged. This mode is used by window manager in most cases.public static final int RESIZE_MODE_PRESERVE_WINDOW
IActivityManager.resizeTask(int, android.graphics.Rect, int)
which indicates
that the resize should preserve the window if possible.public static final int RESIZE_MODE_FORCED
IActivityManager.resizeTask(int, android.graphics.Rect, int)
which indicates
that the resize should be performed even if the bounds appears unchanged.public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION
IActivityManager.resizeTask(int, android.graphics.Rect, int)
used by window
manager during a screen rotation.public static final int RESIZE_MODE_USER
IActivityManager.resizeTask(int, android.graphics.Rect, int)
used when the
resize is due to a drag action.public static final int RESIZE_MODE_USER_FORCED
IActivityManager.resizeTask(int, android.graphics.Rect, int)
which indicates
that the resize should preserve the window if possible, and should not be skipped
even if the bounds is unchanged. Usually used to force a resizing when a drag action
is ending.public static final int RECENT_WITH_EXCLUDED
getRecentTasks(int, int)
: return all tasks, even those
that have set their
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
flag.public static final int RECENT_IGNORE_UNAVAILABLE
public static final int RECENT_INCLUDE_PROFILES
public static final int RECENT_IGNORE_HOME_STACK_TASKS
public static final int RECENT_INGORE_DOCKED_STACK_TOP_TASK
public static final int RECENT_INGORE_PINNED_STACK_TASKS
public static final int MOVE_TASK_WITH_HOME
moveTaskToFront(int, int)
: also move the "home"
activity along with the task, so it is positioned immediately behind
the task.public static final int MOVE_TASK_NO_USER_ACTION
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.public static final int FLAG_OR_STOPPED
public static final int FLAG_AND_LOCKED
public static final int FLAG_AND_UNLOCKED
public static final int FLAG_AND_UNLOCKING_OR_UNLOCKED
public static final String ACTION_REPORT_HEAP_LIMIT
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 Intent.ACTION_SEND
. Note that to
match the activty must support this action and a MIME type of "*/*".public static final boolean isProcStateBackground(int procState)
public int getFrontActivityScreenCompatMode()
public void setFrontActivityScreenCompatMode(int mode)
public int getPackageScreenCompatMode(String packageName)
public void setPackageScreenCompatMode(String packageName, int mode)
public boolean getPackageAskScreenCompat(String packageName)
public void setPackageAskScreenCompat(String packageName, boolean ask)
public int getMemoryClass()
public static int staticGetMemoryClass()
public int getLargeMemoryClass()
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.
public static int staticGetLargeMemoryClass()
public boolean isLowRamDevice()
public static boolean isLowRamDeviceStatic()
public static boolean isHighEndGfx()
public static int getMaxRecentTasksStatic()
public static int getDefaultAppRecentsLimitStatic()
public static int getMaxAppRecentsLimitStatic()
public static boolean supportsMultiWindow()
@Deprecated public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags) throws SecurityException
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 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.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.
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
.SecurityException
public List<ActivityManager.RecentTaskInfo> getRecentTasksForUser(int maxNum, int flags, int userId) throws SecurityException
getRecentTasks(int, int)
but returns the recent tasks for a
specific user. It requires holding
the android.Manifest.permission#INTERACT_ACROSS_USERS_FULL
permission.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
.SecurityException
public List<ActivityManager.AppTask> getAppTasks()
SecurityException
public Size getAppTaskThumbnailSize()
ActivityManager.AppTask
thumbnails, for use
with addAppTask(android.app.Activity, android.content.Intent, android.app.ActivityManager.TaskDescription, android.graphics.Bitmap)
.public int addAppTask(Activity activity, Intent intent, ActivityManager.TaskDescription description, Bitmap thumbnail)
ActivityManager.AppTask
for the calling application. This will create a new
recents entry that is added to the end of all existing recents.activity
- The activity that is adding the entry. This is used to help determine
the context that the new recents entry will be in.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 Intent.FLAG_ACTIVITY_NEW_DOCUMENT
and
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.description
- Optional additional description information.thumbnail
- Thumbnail to use for the recents entry. Should be the size given by
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.@Deprecated public List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException
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 retu rn 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.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.
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.SecurityException
public boolean removeTask(int taskId) throws SecurityException
taskId
- Identifier of the task to be removed.SecurityException
public ActivityManager.TaskThumbnail getTaskThumbnail(int id) throws SecurityException
SecurityException
public boolean isInHomeStack(int taskId)
public void moveTaskToFront(int taskId, int flags)
moveTaskToFront(int, int, Bundle)
with a null options argument.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
, MOVE_TASK_NO_USER_ACTION
.public void moveTaskToFront(int taskId, int flags, Bundle options)
android.Manifest.permission#REORDER_TASKS
or a SecurityException will be thrown.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
, MOVE_TASK_NO_USER_ACTION
.options
- Additional options for the operation, either null or
as per Context.startActivity(Intent, Bundle)
.public List<ActivityManager.RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException
Note: this method is only intended for debugging or implementing service management type user interfaces.
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.SecurityException
public PendingIntent getRunningServiceControlPanel(ComponentName service) throws SecurityException
SecurityException
public void getMemoryInfo(ActivityManager.MemoryInfo outInfo)
ComponentCallbacks2.onTrimMemory(int)
is the preferred way to do this.
Also see 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.public boolean clearApplicationUserData(String packageName, IPackageDataObserver observer)
public boolean clearApplicationUserData()
true
if the application successfully requested that the application's
data be erased; false
otherwise.public ParceledListSlice<UriPermission> getGrantedUriPermissions(String packageName)
Typically called by Settings.
packageName
- application to look for the granted permissionspublic void clearGrantedUriPermissions(String packageName)
Typically called by Settings.
packageName
- application to clear its granted permissionspublic List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
public List<ApplicationInfo> getRunningExternalApplications()
Note: this method is only intended for debugging or building a user-facing process management UI.
public boolean setProcessMemoryTrimLevel(String process, int userId, int level)
Note: this method is only intended for testing framework.
public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
Note: this method is only intended for debugging or building a user-facing process management UI.
public int getPackageImportance(String packageName)
ActivityManager.RunningAppProcessInfo
, giving you the highest importance of all the
processes that this package has code running inside of. If there are no processes
running its code, ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE
is returned.public static void getMyMemoryState(ActivityManager.RunningAppProcessInfo outState)
ActivityManager.RunningAppProcessInfo
. The
only fields that will be filled in are
ActivityManager.RunningAppProcessInfo.pid
,
ActivityManager.RunningAppProcessInfo.uid
,
ActivityManager.RunningAppProcessInfo.lastTrimLevel
,
ActivityManager.RunningAppProcessInfo.importance
,
ActivityManager.RunningAppProcessInfo.lru
, and
ActivityManager.RunningAppProcessInfo.importanceReasonCode
.public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Note: this method is only intended for debugging or building a user-facing process management UI.
pids
- The pids of the processes whose memory usage is to be
retrieved.@Deprecated public void restartPackage(String packageName)
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.public void killBackgroundProcesses(String packageName)
You must hold the permission
android.Manifest.permission#KILL_BACKGROUND_PROCESSES
to be able to
call this method.
packageName
- The name of the package whose processes are to
be killed.public void killUid(int uid, String reason)
uid
- The UID to kill.reason
- The reason for the kill.public void forceStopPackageAsUser(String packageName, int userId)
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.
packageName
- The name of the package to be stopped.userId
- The user for which the running package is to be stopped.public void forceStopPackage(String packageName)
forceStopPackageAsUser(String, int)
public ConfigurationInfo getDeviceConfigurationInfo()
public int getLauncherLargeIconDensity()
public int getLauncherLargeIconSize()
public static boolean isUserAMonkey()
public static boolean isRunningInTestHarness()
public static int checkComponentPermission(String permission, int uid, int owningUid, boolean exported)
public static int checkUidPermission(String permission, int uid)
public static int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, String name, String callerPackage)
callingPid
- The pid of the incoming call, as per Binder.getCallingPid().callingUid
- The uid of the incoming call, as per Binder.getCallingUid().userId
- The user id argument supplied by the caller -- this is the user
they want to run as.allowAll
- If true, we will allow USER_ALL. This means you must be prepared
to get a USER_ALL returned and deal with it correctly. If false,
an exception will be thrown if USER_ALL is supplied.requireFull
- If true, the caller must hold
android.Manifest.permission#INTERACT_ACROSS_USERS_FULL
to be able to run as a
different user than their current process; otherwise they must hold
android.Manifest.permission#INTERACT_ACROSS_USERS
.name
- Optional textual name of the incoming call; only for generating error messages.callerPackage
- Optional package name of caller; only for error messages.public static int getCurrentUser()
public boolean switchUser(int userid)
userid
- the user's id. Zero indicates the default user.public static void logoutCurrentUser()
public boolean isUserRunning(int userId)
userid
- the user's id. Zero indicates the default user.public boolean isVrModePackageEnabled(ComponentName component)
public void dumpPackageState(FileDescriptor fd, String packageName)
android.Manifest.permission#DUMP
permission to make this call.fd
- 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.packageName
- The name of the package that is to be dumped.public static void dumpPackageStateStatic(FileDescriptor fd, String packageName)
public void setWatchHeapLimit(long pssSize)
clearWatchHeapLimit()
.
This API only work if the calling process has been marked as
ApplicationInfo.FLAG_DEBUGGABLE
or this is running on a debuggable
(userdebug or eng) build.
Callers can optionally implement ACTION_REPORT_HEAP_LIMIT
to directly
handle heap limit reports themselves.
pssSize
- The size in bytes to set the limit at.public void clearWatchHeapLimit()
setWatchHeapLimit(long)
.public void startLockTaskMode(int taskId)
public void stopLockTaskMode()
public boolean isInLockTaskMode()
getLockTaskModeState()
instead.Activity.startLockTask()
public int getLockTaskModeState()
LOCK_TASK_MODE_NONE
, LOCK_TASK_MODE_LOCKED
and LOCK_TASK_MODE_PINNED
.Activity.startLockTask()
public static void setVrThread(int tid)
tid
- tid of the VR threadProcess.myTid()