title: See Android recent task executed by the user
body: <p>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 last application executed by the user. For example, if I execute the calculator application and after that the recent task application that I made, this application shoul be able to tell me something like: "the last application you've executed is 'calculator' and the PID is '2222'".</p>
  
  <p>I was checking on Android developers web page for some code and this is what I found, but I don't know how to implement for Android.</p>
  
  <p><code>ActivityManager.RecentTaskInfo</code> Information you can retrieve about tasks that the user has most recently started or visited.</p>
  
  <p><code>ActivityManager.RunningServiceInfo</code> Information you can retrieve about a particular Service that is currently running in the system.</p>
  
  <p>any suggestion,</p>
  
  <p>Best regards</p>
  
  <p><code>ActivityManager.RunningTaskInfo</code> Information you can retrieve about a particular task that is currently "running" in the system. </p>