I have this code to load icon and application name , but it is slow for more than 50 application and it takes 7-8 sec to load , how to load application name and Icon faster ?
private void loadApps() {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
InternalDataManager.apps = getPackageManager()
.queryIntentActivities(mainIntent, 0);
PackageManager pm = getPackageManager();
for (int i = 0; i < InternalDataManager.apps.size(); i++) {
ResolveInfo info = InternalDataManager.apps.get(i);
// PInfo holds name and icon
PInfo infoP = new InternalDataManager.PInfo();
infoP.appname = info.activityInfo.applicationInfo.loadLabel(pm)
.toString();
infoP.icon = info.activityInfo.loadIcon(pm);
infoP.pname = info.activityInfo.applicationInfo.packageName;
}
}
This helper function retrieves all installed apps with the application name, package name, version-number and -code as well as the icons. The method getPackages() returns an ArrayList with all the apps. You should try this…