title: How to get recent tasks on Android "L"?
body: <h2>Background</h2>
  
  <p><a href="https://play.google.com/store/apps/details?id=com.lb.app_manager">My app</a> allows to sort an apps list by the time they were recently launched .</p>
  
  <h2>The problem</h2>
  
  <p>As of Android "L" , the function <a href="http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks%28int,%20int%29"><strong>getRecentTasks</strong></a> will just return the list of apps that the current app has launched, as written in the <a href="https://developer.android.com/preview/api-overview.html#Behaviors"><strong>documentation</strong></a>:</p>
  
  <blockquote>
    <p>If your app uses ActivityManager.getRecentTasks()...</p>
    
    <p>With the introduction of the new concurrent documents and activities
    tasks feature in the upcoming release (see Concurrent documents and
    activities in Recents screen below), the
    ActivityManager.getRecentTasks() method is now deprecated to improve
    user privacy. For backward compatibility, this method still returns a
    small subset of its data, including the calling application’s own
    tasks and possibly some other non-sensitive tasks (such as Home). If
    your app is using this method to retrieve its own tasks, use
    android.app.ActivityManager.getAppTasks() instead to retrieve that
    information.</p>
  </blockquote>
  
  <p>Same is written when using ADT to show the documentation of this function (not currently available on the Internet) :</p>
  
  <blockquote>
    <p>This method is deprecated. As of L, this method is no longer available
    to third party applications: as the introduction of document-centric
    recents means it can leak personal information to the caller. For
    backwards compatibility, it will still return a small subset of its
    data: at least the caller's own tasks (though see getAppTasks() for
    the correct supported way to retrieve that information), and possibly
    some other tasks such as home that are known to not be sensitive.</p>
  </blockquote>
  
  <p>I don't get why this act was taken, as it's easy to see which apps the user has, and even without any permission.</p>
  
  <p>Thing is, this is a big restriction for this feature that I've added, so I hope there is a way to overcome this.</p>
  
  <h2>What I've tried</h2>
  
  <p>For now, I only used a heuristic way about which apps were recently launched - I get the list of running processes instead.</p>
  
  <p>I could also use the importance value of the processes and maybe the "importanceReasonComponent" , but this is just all heuristics and guesses ... </p>
  
  <h2>The question</h2>
  
  <p>Is there a way to overcome this restriction? Any workaround I haven't thought of?</p>
  
  <p>Maybe it's possible with root? Or BusyBox ?</p>