我有这段代码来加载图标和应用程序名称,但是超过 50 个应用程序速度很慢,加载需要 7-8 秒,如何更快地加载应用程序名称和图标?
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;
}
}