我想读取所有正在运行的应用程序的包名称。
这是我阅读运行应用程序的代码:
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());
}
}
输出 :
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
但这仅显示LifeCycle 中具有运行状态的应用程序。
我如何阅读所有(包括运行状态和暂停状态)任务?