好吧,在尝试使其易于阅读并在此处发布时,我找到了解决方案。这是神奇的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.apps_list_view);
rowItems = new ArrayList<AppListRowItem>();
List<PackageInfo> packs = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
for(int i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
Pinfo newInfo = new Pinfo();
newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
newInfo.pname = p.packageName;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
PackageNames = p.packageName;
AppNames = p.applicationInfo.loadLabel(getPackageManager()).toString();
test = p.applicationInfo.loadIcon(getPackageManager());
AppListRowItem item = new AppListRowItem(test, AppNames, PackageNames);
rowItems.add(item);
}
其他一切就像上面发布的链接一样。