Android中获取应用系统中应用信息接口:PackageManager、ApplicationInfo
官方文档https://developer.android.com/reference/android/content/pm/PackageManager.html
private ArrayList<HashMap<String, Drawable>> getAppList() {
PackageManager pManager = getPackageManager();List<ApplicationInfo> applications = pManager.getInstalledApplications(0);
ArrayList<HashMap<String, Drawable>> list = null;
if (applications != null && applications.size() > 0) {
list = new ArrayList<HashMap<String, Drawable>>();
HashMap<String, Drawable> map = null;
for (ApplicationInfo applicationInfo : applications) {
map = new HashMap<String, Drawable>();
String name = applicationInfo.loadLabel(pManager).toString();
Drawable icon = applicationInfo.loadIcon(pManager);
map.put(name, icon);
list.add(map);
}
}
return list;
}