FlashNotifier/src/main/java/com/pandanomic/flashnotifier/ListFragmentAccessTab.java
private void updateACList() {
        mAppListItems.clear();
        mNewAdapter.notifyDataSetChanged();

        PackageManager packageManager = getActivity().getPackageManager();
        List<PackageInfo> applist = packageManager.getInstalledPackages(0);

        for (PackageInfo pk : applist) {
            if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(PERMISSION, pk.packageName)) {
                HashMap<String, String> data = new HashMap<String, String>();
                data.put("package_name", pk.packageName);
                data.put("app_name", (String) pk.applicationInfo.loadLabel(packageManager));
                mNewAdapter.add(data);
            }
        }

        // Sort the apps
        Collections.sort(mAppListItems, new Comparator<Map<String, String>>() {
            @Override
            public int compare(Map<String, String> lhs, Map<String, String> rhs) {
                return lhs.get("app_name").compareTo(rhs.get("app_name"));
            }
        });

        mNewAdapter.notifyDataSetChanged();
    }
/**
     * Method for sniffing apps that use a certain permission.
     * Based on here: http://stackoverflow.com/a/13028631/3034339
     */
Method for sniffing apps that use a certain permission.
Method for sniffing apps that use a certain permission .
private void updateACList() {
        mAppListItems.clear();
        mNewAdapter.notifyDataSetChanged();
        PackageManager packageManager = getActivity().getPackageManager();
        List<PackageInfo> applist = packageManager.getInstalledPackages(0);
        for (PackageInfo pk : applist) {
            if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(PERMISSION, pk.packageName)) {
                HashMap<String, String> data = new HashMap<String, String>();
                data.put("package_name", pk.packageName);
                data.put("app_name", (String) pk.applicationInfo.loadLabel(packageManager));
                mNewAdapter.add(data);
            }
        }
        Collections.sort(mAppListItems, new Comparator<Map<String, String>>() {
            @Override
            public int compare(Map<String, String> lhs, Map<String, String> rhs) {
                return lhs.get("app_name").compareTo(rhs.get("app_name"));
            }
        });
        mNewAdapter.notifyDataSetChanged();
    }
private void updateACList ( ) { mAppListItems . clear ( ) ; mNewAdapter . notifyDataSetChanged ( ) ; PackageManager packageManager = getActivity ( ) . getPackageManager ( ) ; List < PackageInfo > applist = packageManager . getInstalledPackages ( 0 ) ; for ( PackageInfo pk : applist ) { if ( PackageManager . PERMISSION_GRANTED == packageManager . checkPermission ( PERMISSION , pk . packageName ) ) { HashMap < String , String > data = new HashMap < String , String > ( ) ; data . put ( "package_name" , pk . packageName ) ; data . put ( "app_name" , ( String ) pk . applicationInfo . loadLabel ( packageManager ) ) ; mNewAdapter . add ( data ) ; } } Collections . sort ( mAppListItems , new Comparator < Map < String , String > > ( ) { @ Override public int compare ( Map < String , String > lhs , Map < String , String > rhs ) { return lhs . get ( "app_name" ) . compareTo ( rhs . get ( "app_name" ) ) ; } } ) ; mNewAdapter . notifyDataSetChanged ( ) ; }
Method for sniffing apps that use a certain permission.
Method for sniffing apps that use a certain permission .
// Sort the apps