【发布时间】:2013-12-23 16:44:28
【问题描述】:
Application info 有什么用,如何使用。 我很困惑如何从设备中检索已安装的应用程序并用徽标显示它 谁能帮我解决一下。 区分应用信息、包信息和解析信息这三个术语。
【问题讨论】:
标签: android android-layout android-listview android-fragments
Application info 有什么用,如何使用。 我很困惑如何从设备中检索已安装的应用程序并用徽标显示它 谁能帮我解决一下。 区分应用信息、包信息和解析信息这三个术语。
【问题讨论】:
标签: android android-layout android-listview android-fragments
要显示已安装应用的列表,您可以试试这个
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
您将在 ResolveInfo 中获得启动应用程序所需的所有数据。可以查看ResolveInfo
或试试这个代码
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ArrayList<ResolveInfo> list = (ArrayList<ResolveInfo>)
pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
System.out.println("Installed Applications " + rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
}
【讨论】: