@Override public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) { return mBase.getDrawable(packageName, resid, appInfo); }
@Test public void canResolveDrawableGivenPackageAndResourceId() throws Exception { Drawable drawable = ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source"); shadowPackageManager.addDrawableResolution("com.example.foo", 4334, drawable); Drawable actual = packageManager.getDrawable("com.example.foo", 4334, null); assertThat(actual).isSameAs(drawable); }
@Override public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) { return mBase.getDrawable(packageName, resid, appInfo); }
@Override public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) { return pm.getDrawable(packageName, resid, appInfo); }
@Override public Drawable getDrawable(String packageName, int resId, ApplicationInfo appInfo) { Log.w(TAG, "getDrawable() "); return packageManager.getDrawable(packageName, resId, appInfo); }
public Drawable getIcon(Context context) { final PackageManager pm = context.getPackageManager(); // Use local package for resources when none requested if (mResPackage == null) mResPackage = context.getPackageName(); final boolean validIcon = mResPackage != null && mIconRes != -1; return validIcon ? pm.getDrawable(mResPackage, mIconRes, null) : null; }
public static Drawable getDisplayIcon(Context context, int titleRes, int iconRes, String syncAdapterPackageName) { if (titleRes != -1 && syncAdapterPackageName != null) { final PackageManager pm = context.getPackageManager(); return pm.getDrawable(syncAdapterPackageName, iconRes, null); } else if (titleRes != -1) { return context.getResources().getDrawable(iconRes); } else { return null; } }
@Override public Drawable loadPreview(AppWidgetProviderInfo info) { return mContext.getPackageManager().getDrawable( info.provider.getPackageName(), info.previewImage, null); }
private Drawable getIconForAccount(Account account, AccountManager manager) { AuthenticatorDescription[] descriptions = manager.getAuthenticatorTypes(); for (AuthenticatorDescription description: descriptions) { if (description.type.equals(account.type)) { PackageManager pm = getContext().getPackageManager(); return pm.getDrawable(description.packageName, description.iconId, null); } } return null; }
@Override public Drawable loadPreview(AppWidgetProviderInfo info) { return mContext.getPackageManager().getDrawable( info.provider.getPackageName(), info.previewImage, null); }
@Override public Drawable loadPreview(AppWidgetProviderInfo info) { return mContext.getPackageManager().getDrawable( info.provider.getPackageName(), info.previewImage, null); }
public InstalledPackage(PackageManager pm, ApplicationInfo ai, Drawable defaultIcon) { name = ai.packageName; icon = defaultIcon; pkg = ai.packageName; if (ai.labelRes != 0) { name = (String) pm.getText(ai.packageName, ai.labelRes, ai); } if (ai.icon != 0) { icon = pm.getDrawable(ai.packageName, ai.icon, ai); } }
@Override public Drawable loadPreview(AppWidgetProviderInfo info) { return mContext.getPackageManager().getDrawable( info.provider.getPackageName(), info.previewImage, null); }
public static Drawable loadPackageIcon(Context context, String authority, int icon) { if (icon != 0) { if (authority != null) { final PackageManager pm = context.getPackageManager(); final ProviderInfo info = pm.resolveContentProvider(authority, 0); if (info != null) { return pm.getDrawable(info.packageName, icon, info.applicationInfo); } } else { return ContextCompat.getDrawable(context, icon); } } return null; }
/** * Gets the activity or application icon for an activity. * * @param component Name of an activity. * @return A drawable, or {@code null} if neither the acitivy or the application * have an icon set. */ private Drawable getActivityIcon(ComponentName component) { PackageManager pm = mContext.getPackageManager(); final ActivityInfo activityInfo; try { activityInfo = pm.getActivityInfo(component, PackageManager.GET_META_DATA); } catch (NameNotFoundException ex) { Log.w(LOG_TAG, ex.toString()); return null; } int iconId = activityInfo.getIconResource(); if (iconId == 0) return null; String pkg = component.getPackageName(); Drawable drawable = pm.getDrawable(pkg, iconId, activityInfo.applicationInfo); if (drawable == null) { Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + component.flattenToShortString()); return null; } return drawable; }
@Nullable @Implementation public Drawable getDrawable(String packageName, @DrawableRes int resId, @Nullable ApplicationInfo appInfo) { return getDelegatePackageManager().getDrawable(packageName, resId, appInfo); }