title: Android 6.0: Get package name of current activity
body: <p>How to get current activity package name? as <code>getRunningAppProcesses()</code> not working in Android 6.0.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>grdPhoto.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @TargetApi(Build.VERSION_CODES.LOLLIPOP)
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
          //get package name of current running application.
          ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
          packageName = mActivityManager.getRunningAppProcesses().get(1).processName;
  
          Log.e("Package name:===========      ", "Package name     " + packageName);
  
      }
  });
  </code></pre>