diff options
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 84eb8bfa2..6caa1cf56 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -108,6 +108,27 @@ public final class Utilities { } /** + * Returns a bitmap suitable for the all apps view. If the package or the resource do not + * exist, it returns null. + */ + static Bitmap createIconBitmap(String packageName, String resourceName, IconCache cache, + Context context) { + PackageManager packageManager = context.getPackageManager(); + // the resource + try { + Resources resources = packageManager.getResourcesForApplication(packageName); + if (resources != null) { + final int id = resources.getIdentifier(resourceName, null, null); + return createIconBitmap( + resources.getDrawableForDensity(id, cache.getFullResIconDpi()), context); + } + } catch (Exception e) { + // Icon not found. + } + return null; + } + + /** * Returns a bitmap which is of the appropriate size to be displayed as an icon */ static Bitmap createIconBitmap(Bitmap icon, Context context) { |