title: Cannot get foreground activity name in Android Lollipop 5.0 only
body: <p>I use the following code to get the activity name of the foreground app in the variable <strong>foregroundTaskPackageName</strong>. It works on all OS versions between 4.1 to 4.4, but does not work in Android 5.0 Lollipop.</p>
  
  <p>Can anyone help with what has changed in 5.0 Lollipop? In Lollipop - the text I get for <strong>foregroundTaskPackageName</strong> is just 'Launcher3'. I am using the Genymotion Emulator.</p>
  
  <pre><code>ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  RunningTaskInfo foregroundTaskInfo = am.getRunningTasks(1).get(0); // get
                                                                          // list
                                                                          // of
                                                                          // running
                                                                          // tasks
  String foregroundTaskAppName = null;
  String foregroundTaskPackageName = foregroundTaskInfo.topActivity
                  .getPackageName();
  </code></pre>