How to get all the tasks that are running currently

后端 未结 4 482
轮回少年
轮回少年 2021-01-18 12:43

I want to get all the tasks that are running in android.I found getRunningTasks in ActivityManager but from android-5.0 the getRunningTasks may not give all the tasks (in my

4条回答
  •  孤街浪徒
    2021-01-18 13:31

    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!

    Related Documentation:

    getRunningAppProcesses

    RunningAppProcessInfo

    IMPORTANCE_FOREGROUND

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

提交回复
热议问题