title: how to get top application's activity info in Android Lollipop(5.0) and Above
body: <p>Am Developing an App where i need to recognize the current running app on top, so i have tried with below code </p>
  
  <pre><code> ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
  
      // get the info from the currently running task
      List&lt;ActivityManager.RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1);
  
      ComponentName componentInfo = taskInfo.get(0).topActivity;
      if(!componentInfo.getPackageName().equals("your.package.name"))
      {
          //Do your stuff
      }
  </code></pre>
  
  <p>but its not working on Android Lollipop(5.0) and above, its not returning the current running app information.</p>
  
  <p>please help if any one have any idea to do so on android lollipop(5.0) and above.</p>