Compartilhar via


ActivityManager.GetRunningTasks(Int32) Method

Definition

Caution

deprecated

Return a list of the tasks that are currently running, with the most recent being first and older ones after in order.

[Android.Runtime.Register("getRunningTasks", "(I)Ljava/util/List;", "GetGetRunningTasks_IHandler")]
[System.Obsolete("deprecated")]
public virtual System.Collections.Generic.IList<Android.App.ActivityManager.RunningTaskInfo>? GetRunningTasks (int maxNum);
[<Android.Runtime.Register("getRunningTasks", "(I)Ljava/util/List;", "GetGetRunningTasks_IHandler")>]
[<System.Obsolete("deprecated")>]
abstract member GetRunningTasks : int -> System.Collections.Generic.IList<Android.App.ActivityManager.RunningTaskInfo>
override this.GetRunningTasks : int -> System.Collections.Generic.IList<Android.App.ActivityManager.RunningTaskInfo>

Parameters

maxNum
Int32

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.

Attributes

Exceptions

Remarks

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.

<b>Note: this method is only intended for debugging and presenting task management user interfaces</b>. 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 <em>not</em> 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.

This member is deprecated. As of android.os.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 return 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.

Java documentation for android.app.ActivityManager.getRunningTasks(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to