title: get package name of current application which is open on screen? Not working in lollipop?
body: <p>I am working with custom keyboard ,I need current package name when keyboard is open . This keyboard will be open with different different application ,so i need that application package name which is open currently.
  I am using following code but its not working properly.</p>
  
  <pre><code>  ActivityManager am = (ActivityManager) this
              .getSystemService(Activity.ACTIVITY_SERVICE);
      String packageName = am.getRunningTasks(1).get(0).topActivity
              .getPackageName();
  </code></pre>