実行中のすべてのアプリケーションのパッケージ名を読み取りたい。
実行中のアプリケーションを読み取るための私のコードは次のとおりです。
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 で Running State を持つアプリケーションのみを示しています。
すべてのタスク (実行中の状態と一時停止中の状態を含む) を読み取るにはどうすればよいですか?