title: Get The Current Foreground Activity Name And The Package Name In Lollipop
body: <p>there are lots of question about this topic but all are only about getting the package name. 
  what i want is get the activity name.     </p>
  
  <p>currently i am using the below method to get the activity name but as you know ActivityManager.getRunningTasks is now deprecated, so is there an alternative way to get this or i should stick with this and it won't do any harm?</p>
  
  <pre><code>ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
                      List&lt;ActivityManager.RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1);   //deprecated 
  
  
  //taskInfo.get(0).topActivity.getClassName() //this gets the activity name 
  </code></pre>