Example usage for java.lang Package.PackageNameComparator Package.PackageNameComparator

List of usage examples for java.lang Package.PackageNameComparator Package.PackageNameComparator

Introduction

In this page you can find the example usage for java.lang Package.PackageNameComparator Package.PackageNameComparator.

Prototype

Package.PackageNameComparator

Source Link

Usage

From source file:com.loserskater.suhidegui.utils.Utils.java

private static void getInstalledApps(Context context) {
    ArrayList<Package> packages = new ArrayList<Package>();
    List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(0);
    for (int i = 0; i < packs.size(); i++) {
        PackageInfo p = packs.get(i);/*from   w w w . j  av  a 2  s . c o m*/
        String name = p.applicationInfo.loadLabel(context.getPackageManager()).toString();
        String uid = Integer.toString(p.applicationInfo.uid);
        String packageName = p.applicationInfo.packageName;
        packages.add(new Package(name, uid, packageName));
    }
    Collections.sort(packages, new Package.PackageNameComparator());
    setPackages(packages);
}

From source file:com.loserskater.suhidegui.utils.Utils.java

private static void getRunningProcesses() {
    List<Package> processes = new ArrayList<>();
    if (haveRoot) {
        List<String> processNames = Shell.SU
                .run("for proc in /proc/*[0-9]*/cmdline; do cat \"$proc\"; echo \"\" ;done");
        for (String processName : processNames) {
            if (!processName.trim().isEmpty() && !isBadName(processName)) {
                Package p = new Package(processName.trim(), processName.trim(), null);
                processes.add(p);//  w w  w  . j a  v a  2  s.  com
            }
        }
        Collections.sort(processes, new Package.PackageNameComparator());
    }
    setProcesses(new ArrayList<>(processes));
}