Android Utililty Methods APK Icon Get

List of utility methods to do APK Icon Get

Description

The list of methods to do APK Icon Get are organized into topic(s).

Method

DrawablegetAppIcon(Context c, int uid)
get App Icon
PackageManager pm = c.getPackageManager();
Drawable icon = null;
try {
    String name = pm.getPackagesForUid(uid)[0];
    icon = (Drawable) getAppInfo(c, name).loadIcon(pm);
} catch (NameNotFoundException e) {
    e.printStackTrace();
} catch (NullPointerException e) {
...
DrawablegetAppIcon(Context c, int uid)
get App Icon
PackageManager pm = c.getPackageManager();
Drawable icon = null;
try {
    String name = pm.getPackagesForUid(uid)[0];
    icon = (Drawable) getAppInfo(c, name).loadIcon(pm);
} catch (NameNotFoundException e) {
    e.printStackTrace();
} catch (NullPointerException e) {
...
intgetDensityOptimizedIconSize(final Context context)
get Density Optimized Icon Size
int iconSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
    iconSize = ((ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE))
            .getLauncherLargeIconSize();
} else {
    iconSize = (int) context.getResources().getDimension(
            android.R.dimen.app_icon_size);
...
DrawablegetDensityOptimizedIconSizeDrawable( final Context myAppContext, final Context targetPackageContext, final int resId)
get Density Optimized Icon Size Drawable
int adjustedResId = resId;
if (adjustedResId <= 0) {
    adjustedResId = android.R.drawable.sym_def_app_icon;
int density;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    density = ((ActivityManager) myAppContext
            .getSystemService(Context.ACTIVITY_SERVICE))
...
DrawableshowUninstallAPKIcon(Context c, String apkPath)
show Uninstall APK Icon
String PATH_PackageParser = "android.content.pm.PackageParser";
String PATH_AssetManager = "android.content.res.AssetManager";
try {
    Class<?> pkgParserCls = Class.forName(PATH_PackageParser);
    Class[] typeArgs = new Class[1];
    typeArgs[0] = String.class;
    Constructor<?> pkgParserCt = pkgParserCls
            .getConstructor(typeArgs);
...