KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Hi I followed the below tutorial and successfully listed all of my installed apps in my application. List all installed apps in style However it does not list them alphabetically and i can not figure out how to sort them so that they are. Any help with this would be greatly appreciated. I've tried a few things like this class IgnoreCaseComparator implements Comparator<String> { public int compare(String strA, String strB) { return strA.compareToIgnoreCase(strB); } } IgnoreCaseComparator icc = new IgnoreCaseComparator(); java.util.Collections.sort(SomeArrayList,icc); But can't figure out how to apply it to the app list titles. Thank you for any help with this ===EDIT=== Thank you for the reply I did the following but have an error on sort. The error reads "The method sort(List, Comparator) in the type Collections is not applicable for the arguments (List, ApplicationInfo.DisplayNameComparator)" private List<App> loadInstalledApps(boolean includeSysApps) { List<App> apps = new ArrayList<App>(); PackageManager packageManager = getPackageManager(); List<PackageInfo> packs = packageManager.getInstalledPackages(0); for(int i=0; i < packs.size(); i++) { PackageInfo p = packs.get(i); ApplicationInfo a = p.applicationInfo; if ((!includeSysApps) && ((a.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) { continue; } App app = new App(); app.setTitle(p.applicationInfo.loadLabel(packageManager).toString()); app.setPackageName(p.packageName); app.setVersionName(p.versionName); app.setVersionCode(p.versionCode); CharSequence description = p.applicationInfo.loadDescrip
Tags (comma-separated)
Save Edits
Cancel