Here you can find the source of getAppLabel(Context c, int uid)
public static String getAppLabel(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; public class Main { public static String getAppLabel(Context c, int uid) { PackageManager pm = c.getPackageManager(); String label = null;// w ww .j a va 2 s . c o m try { String name = pm.getPackagesForUid(uid)[0]; label = (String) pm.getApplicationLabel(getAppInfo(c, name)); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e) { label = "unknown(uid=" + uid + ")"; } return label; } private static ApplicationInfo getAppInfo(Context c, String name) throws NameNotFoundException { PackageManager pm = c.getPackageManager(); return pm.getApplicationInfo(name, PackageManager.GET_UNINSTALLED_PACKAGES); } }