Esempio n. 1
0
  /** Returns a high res icon for the given intent and user */
  public synchronized Bitmap getIcon(Intent intent, UserHandleCompat user) {
    ComponentName component = intent.getComponent();
    // null info means not installed, but if we have a component from the intent then
    // we should still look in the cache for restored app icons.
    if (component == null) {
      return getDefaultIcon(user);
    }

    LauncherActivityInfoCompat launcherActInfo = mLauncherApps.resolveActivity(intent, user);
    CacheEntry entry = cacheLocked(component, launcherActInfo, user, true, false /* useLowRes */);
    return entry.icon;
  }
Esempio n. 2
0
 /**
  * Fill in {@param shortcutInfo} with the icon and label for {@param intent}. If the corresponding
  * activity is not found, it reverts to the package icon.
  */
 public synchronized void getTitleAndIcon(
     ShortcutInfo shortcutInfo, Intent intent, UserHandleCompat user, boolean useLowResIcon) {
   ComponentName component = intent.getComponent();
   // null info means not installed, but if we have a component from the intent then
   // we should still look in the cache for restored app icons.
   if (component == null) {
     shortcutInfo.setIcon(getDefaultIcon(user));
     shortcutInfo.title = "";
     shortcutInfo.usingFallbackIcon = true;
     shortcutInfo.usingLowResIcon = false;
   } else {
     LauncherActivityInfoCompat info = mLauncherApps.resolveActivity(intent, user);
     getTitleAndIcon(shortcutInfo, component, info, user, true, useLowResIcon);
   }
 }