As mentioned in the comments, you'll first want to get a list of the currently running tasks. You can do so with the following code:
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < recentTasks.size(); i++)
{
Log.d("Executed app", "Application executed : " +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"");
}
Source: How to find the currently running applications programatically in android?
Then once you have the list of current tasks, you'll want to create an Adapter, which will populate your list view. There are two main ways you could do this:
- Use a standard ArrayAdapter and pass in a list of Strings. You would have to generate this list of Strings from the list of tasks that were returned to you. This is a great way to display only a single line of text for each task per list element.
- Extend the standard ArrayAdapter to accept a list of Tasks (RunningTaskInfo) and resolve the content inside the ArrayAdapter subclass. This is necessary if you want to display more than a single line of text for each task per list element, for example, the task ID or an image.
Both examples are explained well in the following tutorial: http://www.vogella.com/articles/AndroidListView/article.html#listview_listviewexample
Finally, you will want to associate your Adapter to your ListView by calling:
listViewReference.setAdapter(yourAdapterReference);
Your ListView will then be populated automatically by your adapter.