private static void updateApplicationInfoTitleAndIcon( PackageManager manager, ResolveInfo info, ApplicationInfo application, Context context) { application.title = info.loadLabel(manager); if (application.title == null) { application.title = info.activityInfo.name; } application.icon = Utilities.createIconThumbnail(info.activityInfo.loadIcon(manager), context); application.filtered = false; }
/** Loads the list of installed applications in mApplications. */ public void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } PackageManager manager = mActivity.getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); // Create a launcher for Glass Settings or we have no way to hit that createGlassSettingsAppInfo(); for (int i = 0; i < count; i++) { ApplicationInfo application = new ApplicationInfo(); ResolveInfo info = apps.get(i); Log.d("Launchyi", info.activityInfo.applicationInfo.packageName); // Let's filter out this app if (!mExcludedApps.contains(info.activityInfo.applicationInfo.packageName)) { application.title = info.loadLabel(manager); application.setActivity( new ComponentName( info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); } } // FIXME: should make a way to clear defaults // PackageManagerclearPackagePreferredActivities in special case // This needs to always be last? } }