public Drawable loadIcon(Context context, RunningState state) {
   if (mPackageInfo != null) {
     Drawable unbadgedIcon = mPackageInfo.loadUnbadgedIcon(state.mPm);
     Drawable icon = state.mPm.getUserBadgedIcon(unbadgedIcon, new UserHandle(mUserId));
     return icon;
   }
   return null;
 }
 @Override
 protected List<AppInfo> doInBackground(Void... objects) {
   List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
   PackageManager packageManager = activity.getPackageManager();
   Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
   for (PackageItemInfo appInfo : appInfos) {
     String packageName = appInfo.packageName;
     if (!isHidden(packageName)) {
       CharSequence label = appInfo.loadLabel(packageManager);
       Drawable icon = appInfo.loadIcon(packageManager);
       if (label != null) {
         labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
       }
     }
   }
   Collections.sort(labelsPackages);
   return labelsPackages;
 }
  static CharSequence makeLabel(PackageManager pm, String className, PackageItemInfo item) {
    if (item != null && (item.labelRes != 0 || item.nonLocalizedLabel != null)) {
      CharSequence label = item.loadLabel(pm);
      if (label != null) {
        return label;
      }
    }

    String label = className;
    int tail = label.lastIndexOf('.');
    if (tail >= 0) {
      label = label.substring(tail + 1, label.length());
    }
    return label;
  }