我有以下代码:
packageManager = getPackageManager();
List<PackageInfo> packageList = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
List<PackageInfo> installedapps = new ArrayList<PackageInfo>();
for(PackageInfo apps: packageList){
if(!isSystemPackage(apps)){
installedapps.add(apps);
}
}
Collections.sort(installedapps, new Comparator<PackageInfo>(){
public int compare(PackageInfo o1, PackageInfo o2) {
return o1.packageName.compareTo(o2.packageName);
}
});
apkList = (ListView) findViewById(R.id.listView);
apkList.setAdapter(new AppInfoAdapter(this, installedapps, packageManager));
installedapps 是设备上所有应用程序减去系统应用程序的列表。我唯一想做的就是按字母顺序对它们进行排序,不太清楚如何。