I would like to watch the recent task of my android phone. I was trying some code from internet but non of them work properly. I just want to get the PID and Name of the las
int numberOfTasks = 1;
ActivityManager m = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
//Get some number of running tasks and grab the first one. getRunningTasks returns newest to oldest
RunningTaskInfo task = m.getRunningTasks(numberOfTasks).get(0);
//Build output
String output = "the last application you've executed is '"+task.id+"' and the PID is '"+task.baseActivity.toShortString()+"'";
getRunningTasks
RunningTaskInfo