开发者

Android: reading Running + Paused State Tasks list

I want to read package name of all running applications.

Here is my Code to read Running applications:

public static getRunningTasks(final Context context) {
    final ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final List<RunningTaskInfo> task = manager.getRunningTasks(Integer.MAX_VALUE);
    for (final RunningTaskInfo info : task) {
        System.out.println("base activity "+info.baseActivity.getPackageName());
    }
}

The output :

10-13 09:08:24.348: INFO/System.out(3295): base activity com.gt.mytest
10-13 09:08:24.348: INFO/System.out(3295): base activity com.android.launcher

But this is showing only the Application wi开发者_开发知识库th Running State in LifeCycle.

How can i read all(including Running State and Paused State) tasks?


I found what's wrong, That was my silly mistake

I used

 List<RunningAppProcessInfo> service = manager.getRunningAppProcesses();

instead of

List<RunningTaskInfo> task = manager.getRunningTasks(Integer.MAX_VALUE); 

and got solution. :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜