且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取当前正在运行的所有任务

更新时间:2021-07-06 01:54:04

使用 getRunningAppProcesses ,这将返回 RunningAppProcessInfo 对象的列表,这些对象将为您提供有关每个对象的一些数据正在运行的应用程序.您可以获取的有关该应用程序的信息之一是其 importance (重要性),其值可以为 IMPORTANCE_FOREGROUND ,表示该进程是当前活动的应用程序!

Use getRunningAppProcesses, which will return a list of RunningAppProcessInfo objects that will give you some data about each running app. One of the pieces of information you can retrieve about the app is its importance, which can have a value IMPORTANCE_FOREGROUND which indicates that the process is the currently active application!

相关文档:

getRunningAppProcesses

RunningAppProcessInfo

IMPORTANCE_FOREGROUND

如果这对您有帮助,请随时按向左的箭头:)

If this helped you, feel free to press that arrow to the left :)