Java Code Examples for android.content.pm.ResolveInfo#getIconResource()

The following examples show how to use android.content.pm.ResolveInfo#getIconResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolverActivity.java    From container with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: ShareDialogAdapter.java    From delion with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: ShareDialogAdapter.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: ShareDialogAdapter.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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);
}