Sort Android Apps Alphabetically?
I have the following code: packageManager = getPackageManager(); List packageList = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
Solution 1:
From what I understand, you want to sort a list of PackageInfo
objects alphabetically by name. I would start here. What you want to do is create a custom Comparator for the ArrayList you called installedapps
and then sort is using Collections.sort(..)
. The property of PackageInfo
you should use for sorting is p.packageName
which is the fully qualified name of the Application (you can use regular expressions to isolate the last piece of the package name). An example of isolating cosmetic properties of apps you can find here.
Solution 2:
Android provides an ApplicationInfo.DisplayNameComparator which can be used for sorting of
List<ApplicationInfo>
Check out: Alphabatize list of installed apps
Post a Comment for "Sort Android Apps Alphabetically?"