title: Android get UsageStatsManager in API level 21
body: <p>I need to get info about recent apps usage.</p>
  
  <p>Before API 21 it was used <a href="https://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks(int)" rel="noreferrer">getRunningTasks</a> or <a href="https://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int,%20int)" rel="noreferrer">getRecentTasks</a> to get this info. These methods were deprecated in API 21 according docs.</p>
  
  <p>There is <a href="https://developer.android.com/reference/android/app/usage/UsageStatsManager.html" rel="noreferrer">UsageStatsManager</a> class now, introduced in API level 21.<br>
  <strong>But!</strong> Context.getSystemService(UsageStatsService) <a href="https://developer.android.com/reference/android/content/Context.html#USAGE_STATS_SERVICE" rel="noreferrer"><strong>was added only in API level 22!</strong></a></p>
  
  <p>The question is - <strong>how to get needed data in API 21</strong>?? According <a href="https://developer.android.com/about/dashboards/index.html" rel="noreferrer">dashboards</a>, there is 13% of users at this API level, I don't wanna lose them.</p>