@Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { return mBase.getActivityIcon(activityName); }
@Override public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { return mBase.getActivityIcon(intent); }
private void loadIcon(TypedArray a, PackageManager pm, ApplicationInfo appInfo) { if (mContext instanceof Activity) { try { mIcon = pm.getActivityIcon(((Activity) mContext).getComponentName()); } catch (NameNotFoundException e) { Log.e(TAG, "Failed to load app icon.", e); } } if (mIcon == null) { mIcon = appInfo.loadIcon(pm); } }
@Test public void queryActivityIcons_Match() throws Exception { Intent i = new Intent(); i.setComponent(new ComponentName(TEST_PACKAGE_NAME, "")); Drawable d = new BitmapDrawable(); shadowPackageManager.addActivityIcon(i, d); assertThat(packageManager.getActivityIcon(i)).isSameAs(d); assertThat(packageManager.getActivityIcon(i.getComponent())).isSameAs(d); }
@Override public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { return mBase.getActivityIcon(intent); }
@Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { return mBase.getActivityIcon(activityName); }
private Drawable getDefaultAppDrawable(ComponentName componentName, UserHandle userHandle) { try { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LauncherApps launcher = (LauncherApps) ctx.getSystemService(Context.LAUNCHER_APPS_SERVICE); LauncherActivityInfo info = launcher.getActivityList(componentName.getPackageName(), userHandle.getRealHandle()).get(0); return info.getBadgedIcon(0); } else { return pm.getActivityIcon(componentName); } } catch (NameNotFoundException | IndexOutOfBoundsException e) { Log.e(TAG, "Unable to found component " + componentName.toString() + e); return null; } }
String activityName = mainPackage.activityInfo.name; ComponentName className = new ComponentName(packageName, activityName); appDrawable = context.getPackageManager().getActivityIcon(className); } else {
@Override public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { return pm.getActivityIcon(intent); }
@Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { return packageManager.getActivityIcon(activityName); }
@Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { return pm.getActivityIcon(activityName); }
/** * Get the icon of the calling activity as a Drawable if data about * the calling activity is available. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @return The calling Activity's icon or null if unknown */ public Drawable getCallingActivityIcon() { if (mCallingActivity == null) return null; PackageManager pm = mActivity.getPackageManager(); try { return pm.getActivityIcon(mCallingActivity); } catch (NameNotFoundException e) { Log.e(TAG, "Could not retrieve icon for calling activity", e); } return null; }
/** * Get the icon of the calling activity as a Drawable if data about * the calling activity is available. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @return The calling Activity's icon or null if unknown */ public Drawable getCallingActivityIcon() { if (mCallingActivity == null) return null; PackageManager pm = mActivity.getPackageManager(); try { return pm.getActivityIcon(mCallingActivity); } catch (NameNotFoundException e) { Log.e(TAG, "Could not retrieve icon for calling activity", e); } return null; }
Drawable icon = null; ComponentName componentName = intent.getComponent(); String packageName = componentName.getPackageName(); PackageManager pm = this.getPackageManager(); icon = pm.getActivityIcon(intent);
public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { return getDelegatePackageManager().getActivityIcon(intent); }
@Override protected Pair<Drawable, CharSequence> doInBackground(Void... params) { Drawable directShareIcon = null; CharSequence directShareTitle = null; try { directShareIcon = pm.getActivityIcon(component); ApplicationInfo ai = pm.getApplicationInfo(component.getPackageName(), 0); directShareTitle = pm.getApplicationLabel(ai); } catch (NameNotFoundException exception) { // Use the default null values. } return new Pair<Drawable, CharSequence>( directShareIcon, directShareTitle); } };
continue; Drawable applicationIcon = packageManager.getActivityIcon(intentOfStartActivity); if(applicationIcon != null && !defaultActivityIcon.equals(applicationIcon)) { filteredPackages.add(each);
@Implementation public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { return getDelegatePackageManager().getActivityIcon(activityName); }
/** * Pre-load an icon into the persistent cache. * * <P>Queries for a component that does not exist in the package manager * will be answered by the persistent cache. * * @param componentName the icon should be returned for this component * @param icon the icon to be persisted * @param dpi the native density of the icon */ public void preloadIcon(ComponentName componentName, Bitmap icon, int dpi, String label, long userSerial, InvariantDeviceProfile idp) { // TODO rescale to the correct native DPI try { PackageManager packageManager = mContext.getPackageManager(); packageManager.getActivityIcon(componentName); // component is present on the system already, do nothing return; } catch (PackageManager.NameNotFoundException e) { // pass } ContentValues values = newContentValues( Bitmap.createScaledBitmap(icon, idp.iconBitmapSize, idp.iconBitmapSize, true), label, Color.TRANSPARENT); values.put(IconDB.COLUMN_COMPONENT, componentName.flattenToString()); values.put(IconDB.COLUMN_USER, userSerial); mIconDb.getWritableDatabase().insertWithOnConflict(IconDB.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); }
/** * Pre-load an icon into the persistent cache. * * <P>Queries for a component that does not exist in the package manager * will be answered by the persistent cache. * * @param componentName the icon should be returned for this component * @param icon the icon to be persisted * @param dpi the native density of the icon */ public void preloadIcon(ComponentName componentName, Bitmap icon, int dpi, String label, long userSerial, InvariantDeviceProfile idp) { // TODO rescale to the correct native DPI try { PackageManager packageManager = mContext.getPackageManager(); packageManager.getActivityIcon(componentName); // component is present on the system already, do nothing return; } catch (PackageManager.NameNotFoundException e) { // pass } icon = Bitmap.createScaledBitmap(icon, idp.iconBitmapSize, idp.iconBitmapSize, true); Bitmap lowResIcon = generateLowResIcon(icon, Color.TRANSPARENT); ContentValues values = newContentValues(icon, lowResIcon, label, componentName.getPackageName()); values.put(IconDB.COLUMN_COMPONENT, componentName.flattenToString()); values.put(IconDB.COLUMN_USER, userSerial); mIconDb.insertOrReplace(values); }