如何列出最近/正在运行的应用程序

use*_*040 3 java android

按住手机上的主屏幕按钮会弹出一个弹出窗口,显示最近的应用程序.有谁知道如何通过代码执行相同的操作?我需要能够在列表视图中选择一个.

Rav*_*yas 6

你需要使用 getRunningTasks

来自文档:

public List<ActivityManager.RunningTaskInfo> getRunningTasks (int maxNum)

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