how to get running applications icon on android programmatically
<p>Below here is my code but i am getting default android launcher icon for all running applications:</p>

<pre><code>PackageManager pm = getPackageManager();

            ActivityManager am1 = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);

            List&lt;RunningTaskInfo&gt; processes = am1.getRunningTasks(Integer.MAX_VALUE);

                if (processes != null) {
                    for (int k = 0; k &lt; processes.size(); k++) {
                        // String pkgName = app.getPackageName();
                        String packageName = processes.get(k).topActivity
                                .getPackageName();
                        Drawable ico = null;
                        try
                        {
                         String pName = (String) pm.getApplicationLabel(pm
                                .getApplicationInfo(packageName,
                                        PackageManager.GET_META_DATA));

                            ico = pm.getApplicationIcon(pName);

                        } 
                        catch (NameNotFoundException e) 
                        {
                            Log.e("ERROR", "Unable to find icon for package '"
                                    + packageName + "': " + e.getMessage());
                        }
                        icons.put(processes.get(k).topActivity.getPackageName(),ico);
                    }
</code></pre>
