共用方式為


ActivityManager.GetRecentTasks(Int32, RecentTaskFlags) Method

Definition

Caution

deprecated

[Android.Runtime.Register("getRecentTasks", "(II)Ljava/util/List;", "GetGetRecentTasks_IIHandler")]
[System.Obsolete("deprecated")]
public virtual System.Collections.Generic.IList<Android.App.ActivityManager.RecentTaskInfo>? GetRecentTasks (int maxNum, Android.App.RecentTaskFlags flags);
[<Android.Runtime.Register("getRecentTasks", "(II)Ljava/util/List;", "GetGetRecentTasks_IIHandler")>]
[<System.Obsolete("deprecated")>]
abstract member GetRecentTasks : int * Android.App.RecentTaskFlags -> System.Collections.Generic.IList<Android.App.ActivityManager.RecentTaskInfo>
override this.GetRecentTasks : int * Android.App.RecentTaskFlags -> System.Collections.Generic.IList<Android.App.ActivityManager.RecentTaskInfo>

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 and the maximum number the system can remember.

flags
RecentTaskFlags

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.

Attributes

Exceptions

Remarks

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

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

Java documentation for android.app.ActivityManager.getRecentTasks(int, 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