Here you can find the source of getAppIcon(Context c, int uid)
public static Drawable getAppIcon(Context c, int uid)
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.Drawable; public class Main { public static Drawable getAppIcon(Context c, int uid) { PackageManager pm = c.getPackageManager(); Drawable icon = null;/*from w w w . j av a2 s . c o m*/ try { String name = pm.getPackagesForUid(uid)[0]; icon = (Drawable) getAppInfo(c, name).loadIcon(pm); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e) { icon = null; } return icon; } private static ApplicationInfo getAppInfo(Context c, String name) throws NameNotFoundException { PackageManager pm = c.getPackageManager(); return pm.getApplicationInfo(name, PackageManager.GET_UNINSTALLED_PACKAGES); } }