congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ResolveInfo.getIconResource
Code IndexAdd Tabnine to your IDE (free)

How to use
getIconResource
method
in
android.content.pm.ResolveInfo

Best Java code snippets using android.content.pm.ResolveInfo.getIconResource (Showing top 10 results out of 315)

origin: leolin310148/ShortcutBadger

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void tryNewMiuiBadge(Context context, int badgeCount) throws ShortcutBadgeException {
  if (resolveInfo == null) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
  }
  if (resolveInfo != null) {
    NotificationManager mNotificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification.Builder builder = new Notification.Builder(context)
        .setContentTitle("")
        .setContentText("")
        .setSmallIcon(resolveInfo.getIconResource());
    Notification notification = builder.build();
    try {
      Field field = notification.getClass().getDeclaredField("extraNotification");
      Object extraNotification = field.get(notification);
      Method method = extraNotification.getClass().getDeclaredMethod("setMessageCount", int.class);
      method.invoke(extraNotification, badgeCount);
      mNotificationManager.notify(0, notification);
    } catch (Exception e) {
      throw new ShortcutBadgeException("not able to set badge", e);
    }
  }
}
origin: android-hacker/VirtualXposed

Drawable loadIconForResolveInfo(ResolveInfo ri) {
  Drawable dr;
  try {
    if (ri.resolvePackageName != null && ri.icon != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
      if (dr != null) {
        return dr;
      }
    }
    final int iconRes = ri.getIconResource();
    if (iconRes != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
      if (dr != null) {
        return dr;
      }
    }
  } catch (PackageManager.NameNotFoundException e) {
    VLog.e(TAG, "Couldn't find resources for package\n" + VLog.getStackTraceString(e));
  }
  return ri.loadIcon(mPm);
}
origin: stackoverflow.com

intent.setType("image/jpeg");      
intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm),
   ri.getIconResource()));
origin: freshplanet/ANE-Push-Notification

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void tryNewMiuiBadge(Context context, int badgeCount) throws ShortcutBadgeException {
  if (resolveInfo == null) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
  }
  if (resolveInfo != null) {
    NotificationManager mNotificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification.Builder builder = new Notification.Builder(context)
        .setContentTitle("")
        .setContentText("")
        .setSmallIcon(resolveInfo.getIconResource());
    Notification notification = builder.build();
    try {
      Field field = notification.getClass().getDeclaredField("extraNotification");
      Object extraNotification = field.get(notification);
      Method method = extraNotification.getClass().getDeclaredMethod("setMessageCount", int.class);
      method.invoke(extraNotification, badgeCount);
      mNotificationManager.notify(0, notification);
    } catch (Exception e) {
      throw new ShortcutBadgeException("not able to set badge", e);
    }
  }
}
origin: derry/delion

private Drawable loadIconForResolveInfo(ResolveInfo info) {
  try {
    final int iconRes = info.getIconResource();
    if (iconRes != 0) {
      Resources res = mManager.getResourcesForApplication(info.activityInfo.packageName);
      Drawable icon = ApiCompatibilityUtils.getDrawable(res, iconRes);
      return icon;
    }
  } catch (NameNotFoundException | NotFoundException e) {
    // Could not find the icon. loadIcon call below will return the default app icon.
  }
  return info.loadIcon(mManager);
}
origin: fookwood/Launcher3

public Drawable getIcon(int density) {
  int iconRes = mResolveInfo.getIconResource();
  Resources resources = null;
  Drawable icon = null;
  // Get the preferred density icon from the app's resources
  if (density != 0 && iconRes != 0) {
    try {
      resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
      icon = resources.getDrawableForDensity(iconRes, density);
    } catch (NameNotFoundException | Resources.NotFoundException exc) {
    }
  }
  // Get the default density icon
  if (icon == null) {
    icon = mResolveInfo.loadIcon(mPm);
  }
  if (icon == null) {
    resources = Resources.getSystem();
    icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
  }
  return icon;
}
origin: klinker24/launcher3

public Drawable getIcon(int density) {
  int iconRes = mResolveInfo.getIconResource();
  Resources resources = null;
  Drawable icon = null;
  // Get the preferred density icon from the app's resources
  if (density != 0 && iconRes != 0) {
    try {
      resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
      icon = resources.getDrawableForDensity(iconRes, density);
    } catch (NameNotFoundException | Resources.NotFoundException exc) {
    }
  }
  // Get the default density icon
  if (icon == null) {
    icon = mResolveInfo.loadIcon(mPm);
  }
  if (icon == null) {
    resources = Resources.getSystem();
    icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
  }
  return icon;
}
origin: darkskygit/VirtualApp

Drawable loadIconForResolveInfo(ResolveInfo ri) {
  Drawable dr;
  try {
    if (ri.resolvePackageName != null && ri.icon != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
      if (dr != null) {
        return dr;
      }
    }
    final int iconRes = ri.getIconResource();
    if (iconRes != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
      if (dr != null) {
        return dr;
      }
    }
  } catch (PackageManager.NameNotFoundException e) {
    VLog.e(TAG, "Couldn't find resources for package\n" + VLog.getStackTraceString(e));
  }
  return ri.loadIcon(mPm);
}
origin: klinker24/Android-Blur-Launcher

public Drawable getIcon(int density, IconPackHelper helper) {
  if (helper != null && helper.isIconPackLoaded()) {
    int iconId = helper.getResourceIdForActivityIcon(mActivityInfo);
    if (iconId != 0) {
      isThemed = true;
      return helper.getIconPackResources().getDrawableForDensity(iconId, density);
    }
  }
  int iconRes = mResolveInfo.getIconResource();
  Resources resources = null;
  Drawable icon = null;
  // Get the preferred density icon from the app's resources
  if (density != 0 && iconRes != 0) {
    try {
      resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
      icon = resources.getDrawableForDensity(iconRes, density);
    } catch (NameNotFoundException | Resources.NotFoundException exc) {
    }
  }
  // Get the default density icon
  if (icon == null) {
    icon = mResolveInfo.loadIcon(mPm);
  }
  if (icon == null) {
    resources = Resources.getSystem();
    icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
  }
  return icon;
}
origin: bzsome/VirtualApp-x326

Drawable loadIconForResolveInfo(ResolveInfo ri) {
  Drawable dr;
  try {
    if (ri.resolvePackageName != null && ri.icon != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
      if (dr != null) {
        return dr;
      }
    }
    final int iconRes = ri.getIconResource();
    if (iconRes != 0) {
      dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
      if (dr != null) {
        return dr;
      }
    }
  } catch (PackageManager.NameNotFoundException e) {
    VLog.e(TAG, "Couldn't find resources for package\n" + VLog.getStackTraceString(e));
  }
  return ri.loadIcon(mPm);
}
android.content.pmResolveInfogetIconResource

Popular methods of ResolveInfo

  • loadLabel
  • loadIcon
  • <init>
  • toString
  • getClass
  • writeToParcel

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JList (javax.swing)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now