Android中获取应用系统中应用信息接口

来源:互联网 发布:linux运维工程师简历 编辑:程序博客网 时间:2024/06/05 16:27

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;
}
原创粉丝点击