List of usage examples for android.content.pm ActivityInfo loadIcon
public Drawable loadIcon(PackageManager pm)
From source file:com.mods.grx.settings.utils.Utils.java
public static Drawable get_icon_from_intent(Context context, Intent intent) { Drawable drawable = null;//from www . j ava2 s.c o m try { ComponentName c_n = intent.getComponent(); if (c_n != null) { ActivityInfo a_i = context.getPackageManager().getActivityInfo(c_n, 0); if (a_i != null) drawable = a_i.loadIcon(context.getPackageManager()); } } catch (Exception e) { } if (drawable == null) { ResolveInfo ri = context.getPackageManager().resolveActivity(intent, 0); if (ri != null) { try { drawable = ri.loadIcon(context.getPackageManager()); } catch (Exception e) { } } } //if(drawable==null) drawable=context.getDrawable(R.drawable.ic_no_encontrada); return drawable; }
From source file:com.example.android.home.Home.java
/** * Refreshes the recently launched applications stacked over the favorites. The number * of recents depends on how many favorites are present. *//*from w w w.j a v a 2 s . co m*/ /* private void bindRecents() { final PackageManager manager = getPackageManager(); final ActivityManager tasksManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = tasksManager.getRecentTasks( MAX_RECENT_TASKS, 0); final int count = recentTasks.size(); final ArrayList<ApplicationInfo> recents = new ArrayList<ApplicationInfo>(); for (int i = count - 1; i >= 0; i--) { final Intent intent = recentTasks.get(i).baseIntent; if (Intent.ACTION_MAIN.equals(intent.getAction()) && !intent.hasCategory(Intent.CATEGORY_HOME)) { ApplicationInfo info = getApplicationInfo(manager, intent); if (info != null) { info.intent = intent; // if (!mFavorites.contains(info)) { // recents.add(info); // } } } } //mApplicationsStack.setRecents(recents); } */ private static ApplicationInfo getApplicationInfo(PackageManager manager, Intent intent) { final ResolveInfo resolveInfo = manager.resolveActivity(intent, 0); if (resolveInfo == null) { return null; } final ApplicationInfo info = new ApplicationInfo(); final ActivityInfo activityInfo = resolveInfo.activityInfo; info.icon = activityInfo.loadIcon(manager); if (info.title == null || info.title.length() == 0) { info.title = activityInfo.loadLabel(manager); } if (info.title == null) { info.title = ""; } return info; }
From source file:org.mozilla.gecko.GeckoAppShell.java
private static Drawable getDrawableForExtension(PackageManager pm, String aExt) { Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap mtm = MimeTypeMap.getSingleton(); String mimeType = mtm.getMimeTypeFromExtension(aExt); if (mimeType != null && mimeType.length() > 0) intent.setType(mimeType);//from ww w. j a v a 2 s . c o m else return null; List<ResolveInfo> list = pm.queryIntentActivities(intent, 0); if (list.size() == 0) return null; ResolveInfo resolveInfo = list.get(0); if (resolveInfo == null) return null; ActivityInfo activityInfo = resolveInfo.activityInfo; return activityInfo.loadIcon(pm); }